44 lines
771 B
Go
44 lines
771 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"os/signal"
|
||
|
"syscall"
|
||
|
"time"
|
||
|
|
||
|
slack "git.bullercodeworks.com/brian/go-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)
|
||
|
}
|
||
|
|
||
|
// 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...")
|
||
|
a.m.messages <- NewBotMessage("main", "main", slack.Message{Type: "control", Name: "quit"})
|
||
|
}()
|
||
|
for a.running {
|
||
|
time.Sleep(time.Second * 2)
|
||
|
}
|
||
|
fmt.Println("Done")
|
||
|
os.Exit(0)
|
||
|
}
|