Example #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
}
Example #2
0
// Load加载解析配置文件
func Load(configFile string) error {
	allConfig, err := simplejson.ParseFile(configFile)
	if err != nil {
		log.Println("[ERROR] 配置文件格式错误", err)
		return err
	}
	middleJs, err := allConfig.Array()
	if err != nil {
		log.Println("[ERROR] 配置文件格式错误", err)
		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")
		err = project.Watch(name, root, goWay, mainFile, deamon, depends...)
		if err != nil {
			log.Println("[ERROR] 监控Project:", name, " 出错。详细信息如下:")
			fmt.Println(err)
		}
	}
	return err
}