Exemplo n.º 1
0
// Load加载解析配置文件
func Load(configFile string) error {
	content, err := ioutil.ReadFile(configFile)
	if err != nil {
		logger.LogFatalf("读配置文件错误")
		return err
	}
	allConfig, err := simplejson.NewJson(content)
	if err != nil {
		logger.LogFatalf("配置文件格式错误")
		return err
	}
	middleJs, err := allConfig.Array()
	if err != nil {
		logger.LogFatalf("配置文件格式错误")
		return err
	}
	for i, length := 0, len(middleJs); i < length; i++ {
		oneProject := allConfig.GetIndex(i)
		name := oneProject.Get("name").MustString()
		root := oneProject.Get("root").MustString()
		goWay := oneProject.Get("go_way").MustString()
		deamon := oneProject.Get("deamon").MustBool(true)
		mainFile := oneProject.Get("main").MustString()
		depends := oneProject.GetStringSlice("depends")
		project.Watch(name, root, goWay, mainFile, deamon, depends...)
	}
	return err
}
Exemplo n.º 2
0
func init() {
	logger.SetLogLevel(2048)
	runtime.GOMAXPROCS(runtime.NumCPU())
	if AUTOGO_ROOT == "" {
		logger.LogFatalf("Please use the autogo shell cmd,or check the cmd '" + AUTOGO_CMD + "' is right or not.")
	}
	logger.Logf("Start autogo root " + AUTOGO_ROOT)
	flag.StringVar(&configFile, "f", AUTOGO_ROOT+"/config/projects.json", "配置文件:需要监听哪些工程")
	flag.Parse()
}