mirror of
https://github.com/cooperspencer/gickup
synced 2024-11-08 12:09:18 +01:00
fixed the prometheus dependency for cron
This commit is contained in:
parent
79136ae86b
commit
d52d7cc8be
7
main.go
7
main.go
@ -214,11 +214,6 @@ func main() {
|
||||
Int("pairs", pairs).
|
||||
Msg("Configuration loaded")
|
||||
|
||||
if conf.HasAllPrometheusConf() {
|
||||
prometheus.CountSourcesConfigured.Add(float64(conf.Source.Count()))
|
||||
prometheus.CountDestinationsConfigured.Add(float64(conf.Destination.Count()))
|
||||
}
|
||||
|
||||
if conf.HasValidCronSpec() {
|
||||
c := cron.New()
|
||||
logNextRun(conf)
|
||||
@ -229,6 +224,8 @@ func main() {
|
||||
c.Start()
|
||||
|
||||
if conf.HasAllPrometheusConf() {
|
||||
prometheus.CountSourcesConfigured.Add(float64(conf.Source.Count()))
|
||||
prometheus.CountDestinationsConfigured.Add(float64(conf.Destination.Count()))
|
||||
prometheus.Serve(conf.Metrics.Prometheus)
|
||||
} else {
|
||||
PlaysForever()
|
||||
|
@ -66,28 +66,36 @@ type FileLogging struct {
|
||||
}
|
||||
|
||||
func CheckAllValuesOrNone(parent string, theMap map[string]string) bool {
|
||||
allEmpty := true
|
||||
|
||||
missing := false
|
||||
for key, value := range theMap {
|
||||
thisOneIsEmpty := value == ""
|
||||
if !allEmpty && thisOneIsEmpty {
|
||||
log.Fatal().Str("expectedButMissing", key).Msg(
|
||||
if value == "" {
|
||||
log.Warn().Str("expectedButMissing", key).Msg(
|
||||
"A configuration value is expected but not present. Ensure all required configuration is present.")
|
||||
}
|
||||
if !thisOneIsEmpty {
|
||||
allEmpty = false
|
||||
missing = true
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
return !missing
|
||||
}
|
||||
|
||||
func (conf Conf) HasAllPrometheusConf() bool {
|
||||
checks := map[string]string{
|
||||
"listenaddr": conf.Metrics.Prometheus.ListenAddr,
|
||||
"endpoint": conf.Metrics.Prometheus.Endpoint,
|
||||
if len(conf.Metrics.Prometheus.ListenAddr) == 0 && len(conf.Metrics.Prometheus.Endpoint) == 0 {
|
||||
return false
|
||||
} else {
|
||||
checks := map[string]string{
|
||||
"listenaddr": conf.Metrics.Prometheus.ListenAddr,
|
||||
"endpoint": conf.Metrics.Prometheus.Endpoint,
|
||||
}
|
||||
|
||||
ok := CheckAllValuesOrNone("prometheus", checks)
|
||||
|
||||
if !ok {
|
||||
log.Fatal().Str("monitoring", "prometheus").Msg(
|
||||
"Fix the values in the configuration.")
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
return CheckAllValuesOrNone("prometheus", checks)
|
||||
}
|
||||
|
||||
func (conf Conf) MissingCronSpec() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user