package main import ( "fmt" "os" "os/signal" "syscall" "time" "github.com/nlopes/slack" ) var DebugMode = false var a *App func main() { if len(os.Args) > 1 { if os.Args[1] == "-debug" || os.Args[1] == "--debug" { DebugMode = true } } a, err := NewApp() if err != nil { fmt.Println(err) os.Exit(1) } // Monitor the Advent of Code Boards //go m.MonitorAoCBoards() // Monitor incoming Slack messages //go m.MonitorSlackMessages() // Set up a channel to intercept Ctrl+C for graceful shutdowns c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, syscall.SIGTERM) go func() { <-c // Save the changes when the app quits fmt.Println("\nFinishing up...") msg := slack.Message{} msg.Type = "control" msg.Text = "quit" a.m.messages <- NewBotMessage("main", "main", msg) }() for a.running { time.Sleep(time.Second * 2) } fmt.Println("Model has stopped running") fmt.Println("Done") os.Exit(0) }