New supervisor interface
This commit is contained in:
parent
8e2cc9b1d7
commit
4a4702d6cd
|
@ -1,7 +1,7 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
@ -9,25 +9,22 @@ import (
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Supervisor struct {
|
Supervisor struct {
|
||||||
pythonBin string
|
Bin string
|
||||||
pythonWrapper string
|
Wrapper string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// XXX: We're about to spawn hundreds of Python processes
|
// XXX: We're about to spawn hundreds of Python processes
|
||||||
func (s *Supervisor) StartAll(units []string) {
|
func (s *Supervisor) Start(units ...string) {
|
||||||
for _, name := range units {
|
for _, name := range units {
|
||||||
s.Start(name)
|
log.Printf("Starting unit: %s", name)
|
||||||
time.Sleep(500 * time.Millisecond) // Don't spawn processes too fast
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Supervisor) Start(name string) {
|
cmd := exec.Command(s.Bin, s.Wrapper, name)
|
||||||
fmt.Println("Starting unit: " + name)
|
cmd.Stdout = os.Stderr // Sorry
|
||||||
cmd := exec.Command(s.pythonBin, s.pythonWrapper, name)
|
if err := cmd.Start(); err != nil {
|
||||||
cmd.Stdout = os.Stdout // Sorry
|
log.Printf("Failed to start unit: %s (%s)", name, err.Error())
|
||||||
if err := cmd.Start(); err != nil {
|
}
|
||||||
fmt.Println("Failed to start unit: ", name)
|
|
||||||
fmt.Println(err.Error())
|
time.Sleep(200 * time.Millisecond) // Don't spawn processes too fast
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue