Keeping track of children
This commit is contained in:
parent
e21d18d359
commit
f01ebc27cf
@ -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()
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user