- immediate tick flag

- reword Start -> ClockStart etc
This commit is contained in:
Matej Kramny
2017-02-04 22:40:31 -08:00
parent edfd4a51e6
commit b4fa33b8ad
5 changed files with 74 additions and 67 deletions

View File

@@ -21,7 +21,7 @@ import (
const usage = `cachet-monitor
Usage:
cachet-monitor (-c PATH | --config PATH) [--log=LOGPATH] [--name=NAME]
cachet-monitor (-c PATH | --config PATH) [--log=LOGPATH] [--name=NAME] [--immediate]
cachet-monitor -h | --help | --version
cachet-monitor print-config
@@ -38,6 +38,7 @@ Options:
-c PATH.json --config PATH Path to configuration file
-h --help Show this screen.
--version Show version
--immediate Tick immediately (by default waits for first defined interval)
print-config Print example configuration
Environment varaibles:
@@ -53,6 +54,10 @@ func main() {
logrus.Panicf("Unable to start (reading config): %v", err)
}
if immediate, ok := arguments["--immediate"]; ok {
cfg.Immediate = immediate.(bool)
}
if name := arguments["--name"]; name != nil {
cfg.SystemName = name.(string)
}
@@ -73,6 +78,7 @@ func main() {
os.Exit(1)
}
logrus.Debug("Configuration valid")
logrus.Infof("System: %s", cfg.SystemName)
logrus.Infof("API: %s", cfg.API.URL)
logrus.Infof("Monitors: %d\n", len(cfg.Monitors))
@@ -89,7 +95,7 @@ func main() {
logrus.Infof("Starting Monitor #%d:", index)
logrus.Infof("Features: \n - %v", strings.Join(monitor.Describe(), "\n - "))
// go mon.Start(cfg, wg)
go monitor.ClockStart(cfg, wg)
}
signals := make(chan os.Signal, 1)
@@ -98,7 +104,7 @@ func main() {
logrus.Warnf("Abort: Waiting monitors to finish")
for _, mon := range cfg.Monitors {
mon.GetMonitor().Stop()
mon.GetMonitor().ClockStop()
}
wg.Wait()