1
0
Fork 0
This commit is contained in:
Gregory Eremin 2015-02-11 16:03:56 +07:00
parent c95a4dea67
commit c96bc7ad8f
2 changed files with 12 additions and 8 deletions

6
app.go
View File

@ -5,7 +5,9 @@ import (
"github.com/kr/pretty"
"github.com/localhots/confection"
"github.com/localhots/yeast/chain"
"github.com/localhots/yeast/core"
"github.com/localhots/yeast/unit"
)
func init() {
@ -15,8 +17,8 @@ func init() {
func main() {
core.InitConfig()
core.LoadUnits()
core.ParseChains()
unit.LoadUnits(core.Conf().UnitsConfig)
chain.LoadChains(core.Conf().ChainsConfig)
pretty.Println(core.Conf())

View File

@ -5,6 +5,8 @@ import (
"os"
"os/exec"
"time"
"github.com/localhots/yeast/unit"
)
type (
@ -13,19 +15,19 @@ type (
// XXX: We're about to spawn hundreds of Python processes
func (s *Supervisor) StartAll() {
for unit, _ := range Units {
s.Start(unit)
for _, name := range unit.Units() {
s.Start(name)
time.Sleep(500 * time.Millisecond) // Don't spawn processes too fast
}
}
func (s *Supervisor) Start(unit string) {
fmt.Println("Starting unit: " + unit)
func (s *Supervisor) Start(name string) {
fmt.Println("Starting unit: " + name)
conf := Conf().Python
cmd := exec.Command(conf.BinPath, conf.WrapperPath, unit)
cmd := exec.Command(conf.BinPath, conf.WrapperPath, name)
cmd.Stdout = os.Stdout // Sorry
if err := cmd.Start(); err != nil {
fmt.Println("Failed to start unit: ", unit)
fmt.Println("Failed to start unit: ", name)
fmt.Println(err.Error())
}
}