1
0
Fork 0

Supervisor (18+)

This commit is contained in:
Gregory Eremin 2015-02-11 02:51:01 +07:00
parent a845d56b54
commit e789d02e47
2 changed files with 32 additions and 0 deletions

2
app.go
View File

@ -19,5 +19,7 @@ func main() {
core.ParseChains()
pretty.Println(core.Conf())
println("Waiting")
select {}
}

30
core/supervisor.go Normal file
View File

@ -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())
}
}