示例#1
0
文件: beard.go 项目: exupero/beard
func loadCommand(id string) *cmd.Cmd {
	db := connect()
	var conf *config.Config
	err := db.Query(id, nil, &conf)
	logError(err)
	command := cmd.Command(*conf)
	command.Name = id
	return &command
}
示例#2
0
文件: beard.go 项目: exupero/beard
func main() {
	chCmds := make(chan *cmd.Cmd)
	addr, isFound := syscall.Getenv("BEARD_ADDR")
	if !isFound {
		addr = "localhost:8000"
	}
	go startServer(addr, chCmds)

	db := connect()
	var results ViewResults
	err := db.Query("_design/configs/_view/all", nil, &results)
	logError(err)
	for _, row := range results.Rows {
		conf := row.Value
		conf.Name = row.Id
		command := cmd.Command(*conf)
		command.Start()
		go command.KeepAlive()
		chCmds <- &command
	}

	<-make(chan bool)
}