1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper_helper/main.go

44 lines
891 B
Go
Raw Normal View History

2018-12-04 08:32:11 +04:00
// Fantasy World Zookeeper Helper Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package main
import (
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/context"
2018-12-22 18:03:53 +04:00
"lab.wtfteam.pro/fat0troll/fw_zookeeper_helper/local/telegram"
2018-12-04 08:32:11 +04:00
"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()
telegram.New(c)
// CTRL+C handler.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt)
shutdownDone := make(chan bool, 1)
go func() {
signalThing := <-interrupt
if signalThing == syscall.SIGTERM || signalThing == syscall.SIGINT {
c.Logger.Info().Msg("Got " + signalThing.String() + " signal, shutting down...")
shutdownDone <- true
}
}()
<-shutdownDone
os.Exit(0)
}