diff --git a/core/app.go b/core/app.go index 8dac433..c33dc11 100644 --- a/core/app.go +++ b/core/app.go @@ -23,10 +23,7 @@ func NewApp() *App { a := &App{ config: conf, chains: chain.NewBank(conf.C().ChainsConfig, ub), - sv: &Supervisor{ - Bin: conf.C().Python.BinPath, - Wrapper: conf.C().Python.WrapperPath, - }, + sv: NewSupervisor(conf.C().Python.BinPath, conf.C().Python.WrapperPath), } a.chains.Reload() diff --git a/core/supervisor.go b/core/supervisor.go index 1e4f873..55a3d79 100644 --- a/core/supervisor.go +++ b/core/supervisor.go @@ -11,9 +11,18 @@ type ( Supervisor struct { Bin string Wrapper string + procs map[string]*exec.Cmd } ) +func NewSupervisor(bin, wrapper string) *Supervisor { + return &Supervisor{ + Bin: bin, + Wrapper: wrapper, + procs: map[string]*exec.Cmd{}, + } +} + // XXX: We're about to spawn hundreds of Python processes func (s *Supervisor) Start(units ...string) { for _, name := range units { @@ -24,6 +33,7 @@ func (s *Supervisor) Start(units ...string) { if err := cmd.Start(); err != nil { log.Printf("Failed to start unit: %s (%s)", name, err.Error()) } + s.procs[name] = cmd time.Sleep(200 * time.Millisecond) // Don't spawn processes too fast }