diff options
author | Kevin Chabowski <kevin@kch42.de> | 2013-09-12 23:03:15 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2013-09-12 23:03:15 +0200 |
commit | 2a1b5dcffa49ec9edcc55a27ec301ed6f188ac31 (patch) | |
tree | 629dadd8e1951c998f12a818a40871137b72b7ed | |
parent | 0fe336b08f7868d0f7b531cb30c9facfea0f25f2 (diff) | |
download | mailremind-2a1b5dcffa49ec9edcc55a27ec301ed6f188ac31.tar.gz mailremind-2a1b5dcffa49ec9edcc55a27ec301ed6f188ac31.tar.bz2 mailremind-2a1b5dcffa49ec9edcc55a27ec301ed6f188ac31.zip |
Made the checkInterval configurable
-rw-r--r-- | checkmails.go | 11 | ||||
-rw-r--r-- | mailremind.ini | 3 | ||||
-rw-r--r-- | main.go | 1 |
3 files changed, 13 insertions, 2 deletions
diff --git a/checkmails.go b/checkmails.go index c30507d..926f057 100644 --- a/checkmails.go +++ b/checkmails.go @@ -8,10 +8,17 @@ import ( "time" ) -const checkInterval = 30 // TODO: Make this configurable +var checkInterval int64 + +func initCheckmails() { + var err error + if checkInterval, err = conf.GetInt("schedules", "checkInterval"); err != nil { + log.Fatalf("Could not read config schedules.checkInterval: %s", err) + } +} func checkmails() { - ticker := time.NewTicker(checkInterval * time.Second) + ticker := time.NewTicker(time.Duration(checkInterval) * time.Second) for { t := <-ticker.C diff --git a/mailremind.ini b/mailremind.ini index af20b11..eb498d7 100644 --- a/mailremind.ini +++ b/mailremind.ini @@ -26,3 +26,6 @@ exec=msmtp arg1=-a arg2=kch42 +[schedules] +# How often should the schedules be checked? Unit is seconds. +checkInterval=30
\ No newline at end of file @@ -78,6 +78,7 @@ func main() { log.Fatalf("Could not get net.laddr config: %s", err) } + initCheckmails() go checkmails() router := mux.NewRouter() |