emailer configurable interval

This commit is contained in:
Bel LaPointe
2022-01-11 07:50:58 -05:00
parent 6c455764e1
commit 27605997c1
4 changed files with 14 additions and 10 deletions

17
main.go
View File

@@ -21,16 +21,15 @@ var stateFinder = regexp.MustCompile(`[A-Za-z]+`)
func main() {
lock := &sync.Mutex{}
go func() {
c := time.NewTicker(time.Minute)
for range c.C {
if !config.Get().EmailerEnabled {
continue
for {
if config.Get().EmailerEnabled {
lock.Lock()
if err := email(); err != nil {
log.Print(err)
}
lock.Unlock()
}
lock.Lock()
if err := email(); err != nil {
log.Print(err)
}
lock.Unlock()
time.Sleep(config.Get().Interval.Email.Get())
}
}()
if err := _main(); err != nil {