예제 #1
0
파일: v2.go 프로젝트: miros/init-exporter
func mustGetInt(yaml *simpleyaml.Yaml, key string) int {
	if rawVal := yaml.Get(key); isPresent(rawVal) {
		if val, err := rawVal.Int(); err != nil {
			panic(fmt.Sprintf("%s is not integer", key))
		} else {
			return val
		}
	}

	return 0
}
예제 #2
0
파일: v2.go 프로젝트: miros/init-exporter
func getServiceOptions(yaml *simpleyaml.Yaml) ServiceOptions {
	options := ServiceOptions{}

	options.WorkingDirectory, _ = yaml.Get("working_directory").String()
	options.User, _ = yaml.Get("user").String()
	options.Group, _ = yaml.Get("group").String()
	options.KillTimeout = mustGetInt(yaml, "kill_timeout")
	options.LogPath, _ = yaml.Get("log").String()
	options.Count = mustGetInt(yaml, "count")

	if value, err := yaml.Get("env").Map(); err == nil {
		options.Env = toStringMap(value)
	}

	if value := yaml.Get("respawn"); isPresent(value) {
		count := mustGetInt(value, "count")
		interval := mustGetInt(value, "interval")
		options.Respawn = Respawn{Count: count, Interval: interval}
	}

	return options
}