diff --git a/app.go b/app.go index 6ac55dd..bde3fc8 100644 --- a/app.go +++ b/app.go @@ -19,5 +19,7 @@ func main() { core.ParseChains() pretty.Println(core.Conf()) + + println("Waiting") select {} } diff --git a/core/supervisor.go b/core/supervisor.go new file mode 100644 index 0000000..c63f422 --- /dev/null +++ b/core/supervisor.go @@ -0,0 +1,30 @@ +package core + +import ( + "fmt" + "os" + "os/exec" + "time" +) + +type ( + Supervisor struct{} +) + +// XXX: We're about to spawn hundreds of Python processes +func (s *Supervisor) StartAll() { + for unit, _ := range Units { + s.Start(unit) + time.Sleep(500 * time.Millisecond) // Don't spawn processes too fast + } +} + +func (s *Supervisor) Start(unit string) { + fmt.Println("Starting unit: " + unit) + cmd := exec.Command(Conf().Python.BinPath, Conf().Python.WrapperPath, unit) + cmd.Stdout = os.Stdout // Sorry + if err := cmd.Start(); err != nil { + fmt.Println("Failed to start unit: ", unit) + fmt.Println(err.Error()) + } +}