Keeping track of children
This commit is contained in:
parent
e21d18d359
commit
f01ebc27cf
@ -23,10 +23,7 @@ func NewApp() *App {
|
|||||||
a := &App{
|
a := &App{
|
||||||
config: conf,
|
config: conf,
|
||||||
chains: chain.NewBank(conf.C().ChainsConfig, ub),
|
chains: chain.NewBank(conf.C().ChainsConfig, ub),
|
||||||
sv: &Supervisor{
|
sv: NewSupervisor(conf.C().Python.BinPath, conf.C().Python.WrapperPath),
|
||||||
Bin: conf.C().Python.BinPath,
|
|
||||||
Wrapper: conf.C().Python.WrapperPath,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
a.chains.Reload()
|
a.chains.Reload()
|
||||||
|
|
||||||
|
@ -11,9 +11,18 @@ type (
|
|||||||
Supervisor struct {
|
Supervisor struct {
|
||||||
Bin string
|
Bin string
|
||||||
Wrapper 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
|
// XXX: We're about to spawn hundreds of Python processes
|
||||||
func (s *Supervisor) Start(units ...string) {
|
func (s *Supervisor) Start(units ...string) {
|
||||||
for _, name := range units {
|
for _, name := range units {
|
||||||
@ -24,6 +33,7 @@ func (s *Supervisor) Start(units ...string) {
|
|||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
log.Printf("Failed to start unit: %s (%s)", name, err.Error())
|
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
|
time.Sleep(200 * time.Millisecond) // Don't spawn processes too fast
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user