func doMain(argv []string) int { conf, otherOpts := resolveConfig(argv) if conf == nil { return exitStatusError } if otherOpts != nil && otherOpts.printVersion { return doVersion([]string{}) } if conf.Verbose { logging.SetLogLevel(logging.DEBUG) } logger.Infof("Starting mackerel-agent version:%s, rev:%s, apibase:%s", version.VERSION, version.GITCOMMIT, conf.Apibase) if otherOpts != nil && otherOpts.runOnce { command.RunOnce(conf) return exitStatusOK } if conf.Apikey == "" { logger.Criticalf("Apikey must be specified in the command-line flag or in the config file") return exitStatusError } return start(conf) }
func doOnce(argv []string) int { // dirty hack `resolveConfig` required apikey so fill up argvOpt := append(argv, "-apikey=dummy") conf, _ := resolveConfig(argvOpt) if conf == nil { return exitStatusError } command.RunOnce(conf) return exitStatusOK }