gonews/cmd/gonewsd/main.go

42 lines
848 B
Go
Raw Normal View History

2019-09-02 19:51:38 +05:00
package main
import (
// stdlib
"log"
"os"
"os/signal"
"syscall"
// local
"develop.pztrn.name/gonews/gonews/commands"
"develop.pztrn.name/gonews/gonews/configuration"
2019-09-02 19:51:38 +05:00
"develop.pztrn.name/gonews/gonews/eventer"
"develop.pztrn.name/gonews/gonews/networker"
)
func main() {
log.Println("Starting gonewsd...")
configuration.Initialize()
2019-09-02 19:51:38 +05:00
eventer.Initialize()
commands.Initialize()
2019-09-02 19:51:38 +05:00
networker.Initialize()
eventer.InitializeCompleted()
log.Println("gonewsd is up and ready to serve")
// CTRL+C handler.
signalHandler := make(chan os.Signal, 1)
shutdownDone := make(chan bool, 1)
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
go func() {
<-signalHandler
log.Println("CTRL+C or SIGTERM received, shutting down gonewsd...")
shutdownDone <- true
}()
<-shutdownDone
log.Println("gonewsd done")
os.Exit(0)
}