This commit is contained in:
2015-02-11 16:03:56 +07:00
parent c95a4dea67
commit c96bc7ad8f
2 changed files with 12 additions and 8 deletions
+8 -6
View File
@@ -5,6 +5,8 @@ import (
"os"
"os/exec"
"time"
"github.com/localhots/yeast/unit"
)
type (
@@ -13,19 +15,19 @@ type (
// XXX: We're about to spawn hundreds of Python processes
func (s *Supervisor) StartAll() {
for unit, _ := range Units {
s.Start(unit)
for _, name := range unit.Units() {
s.Start(name)
time.Sleep(500 * time.Millisecond) // Don't spawn processes too fast
}
}
func (s *Supervisor) Start(unit string) {
fmt.Println("Starting unit: " + unit)
func (s *Supervisor) Start(name string) {
fmt.Println("Starting unit: " + name)
conf := Conf().Python
cmd := exec.Command(conf.BinPath, conf.WrapperPath, unit)
cmd := exec.Command(conf.BinPath, conf.WrapperPath, name)
cmd.Stdout = os.Stdout // Sorry
if err := cmd.Start(); err != nil {
fmt.Println("Failed to start unit: ", unit)
fmt.Println("Failed to start unit: ", name)
fmt.Println(err.Error())
}
}