mirror of
https://github.com/ChronosX88/openkeepd.git
synced 2024-11-23 11:32:19 +00:00
refactor: Make a skeleton of main.go (openkeepd binary)
This commit is contained in:
parent
225fcd598d
commit
313a3b6af6
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
/openkeepd
|
||||
|
31
cmd/openkeepd/main.go
Normal file
31
cmd/openkeepd/main.go
Normal file
@ -0,0 +1,31 @@
|
||||
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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user