func startIsmonitor(daemonMode bool) { configFile, err := ioutil.ReadFile("config.json") if err != nil { log.Fatalln(err) } var config config err = json.Unmarshal(configFile, &config) if err != nil { log.Fatalln(err) } if daemonMode && config.CronSchedule == nil { fmt.Println("Daemon mode but no cron schedule specified. Quitting.") os.Exit(1) } if !daemonMode && config.CronSchedule != nil { fmt.Println("Daemon mode not specified but a cron schedule specified. Quitting.") os.Exit(1) } if config.CronSchedule != nil { cron := cron.New() cron.AddJob(*config.CronSchedule, monitorJob{&config}) cron.Start() defer cron.Stop() select {} } else { runIsmonitor(config) } }
func RemoveCron(expression string) bool { if cron, ok := global.Crons[expression]; ok { delete(global.Crons, expression) cron.Stop() } else { return false } return true }