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/kr/pretty"
"github.com/localhots/confection" "github.com/localhots/confection"
"github.com/localhots/yeast/chain"
"github.com/localhots/yeast/core" "github.com/localhots/yeast/core"
"github.com/localhots/yeast/unit"
) )
func init() { func init() {
@ -15,8 +17,8 @@ func init() {
func main() { func main() {
core.InitConfig() core.InitConfig()
core.LoadUnits() unit.LoadUnits(core.Conf().UnitsConfig)
core.ParseChains() chain.LoadChains(core.Conf().ChainsConfig)
pretty.Println(core.Conf()) pretty.Println(core.Conf())

View File

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