mirror of
https://github.com/ChronosX88/openkeepd.git
synced 2024-11-09 17:00:59 +00:00
32 lines
590 B
Go
32 lines
590 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var logger = logrus.New()
|
|
|
|
func main() {
|
|
logger.Info("Starting openkeepd server...")
|
|
|
|
logger.Info("Server successfully started!")
|
|
|
|
// CTRL+C handler.
|
|
signalHandler := make(chan os.Signal, 1)
|
|
shutdownDone := make(chan bool, 1)
|
|
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
|
|
go func() {
|
|
<-signalHandler
|
|
logger.Info("CTRL+C or SIGTERM received, shutting down openkeepd...")
|
|
shutdownDone <- true
|
|
}()
|
|
|
|
<-shutdownDone
|
|
logger.Info("Server successfully shutted down")
|
|
os.Exit(0)
|
|
}
|