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

48 lines
1011 B
Go
Raw Permalink 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 (
2019-10-08 05:40:29 +04:00
"source.hodakov.me/fat0troll/fwzookeeper_helper/context"
"source.hodakov.me/fat0troll/fwzookeeper_helper/domains/announces/v1"
"source.hodakov.me/fat0troll/fwzookeeper_helper/internal/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()
2019-02-12 03:06:00 +04:00
announcesv1.New(c)
telegram.New(c)
2018-12-04 08:32:11 +04:00
// CTRL+C handler.
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt)
2019-02-12 03:06:00 +04:00
shutdownDone := make(chan bool, 1)
2018-12-04 08:32:11 +04:00
go func() {
signalThing := <-interrupt
if signalThing == syscall.SIGTERM || signalThing == syscall.SIGINT {
c.Logger.Info().Msg("Got " + signalThing.String() + " signal, shutting down...")
telegram.Shutdown()
2019-02-12 03:06:00 +04:00
shutdownDone <- true
2018-12-04 08:32:11 +04:00
}
}()
2019-02-12 03:06:00 +04:00
<-shutdownDone
2018-12-04 08:32:11 +04:00
os.Exit(0)
}