48 lines
974 B
Go
48 lines
974 B
Go
// Fantasy World Zookeeper Helper Bot
|
|
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
|
|
|
|
package main
|
|
|
|
import (
|
|
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/context"
|
|
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/domains/announces/v1"
|
|
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/local/telegram"
|
|
"os"
|
|
"os/signal"
|
|
"runtime"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
// Before any real work - lock to OS thread. We shouldn't leave it until
|
|
// shutdown
|
|
runtime.LockOSThread()
|
|
|
|
// Initializing context
|
|
|
|
c := context.NewContext()
|
|
c.Init()
|
|
c.InitConfiguration()
|
|
|
|
// CTRL+C handler.
|
|
interrupt := make(chan os.Signal, 1)
|
|
signal.Notify(interrupt)
|
|
go func() {
|
|
signalThing := <-interrupt
|
|
if signalThing == syscall.SIGTERM || signalThing == syscall.SIGINT {
|
|
c.Logger.Info().Msg("Got " + signalThing.String() + " signal, shutting down...")
|
|
|
|
telegram.Shutdown()
|
|
|
|
c.ShutdownDone <- true
|
|
}
|
|
}()
|
|
|
|
announcesv1.New(c)
|
|
telegram.New(c)
|
|
|
|
<-c.ShutdownDone
|
|
os.Exit(0)
|
|
|
|
}
|