-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
37 lines (28 loc) · 824 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"flag"
"fmt"
"os"
"os/signal"
"syscall"
"gopkg.in/robfig/cron.v2"
"github.com/cpanato/mattermost-away-reminder/server"
)
func main() {
var flagConfigFile string
flag.StringVar(&flagConfigFile, "config", "config-away.json", "")
flag.Parse()
server.LoadConfig(flagConfigFile)
server.Start()
stopChan := make(chan os.Signal)
signal.Notify(stopChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
timeToPost := fmt.Sprintf("@every %vh", server.Config.WebhookNotificationTimeInHours)
fmt.Printf("Will post the time away every %v hours\n", server.Config.WebhookNotificationTimeInHours)
c := cron.New()
c.AddFunc(timeToPost, server.PostAways)
c.AddFunc("@daily", server.RemoveOldAways)
go c.Start()
sig := make(chan os.Signal)
signal.Notify(sig, os.Interrupt, os.Kill)
<-sig
}