giredore/cmd/giredored/main.go

43 lines
812 B
Go
Raw Permalink Normal View History

package main
import (
"os"
"os/signal"
"syscall"
serverv1 "go.dev.pztrn.name/giredore/domains/server/v1"
"go.dev.pztrn.name/giredore/internal/configuration"
"go.dev.pztrn.name/giredore/internal/httpserver"
"go.dev.pztrn.name/giredore/internal/logger"
)
func main() {
logger.Initialize()
logger.Logger.Info().Msg("Starting giredore server...")
configuration.Initialize()
httpserver.Initialize()
serverv1.Initialize()
httpserver.Start()
logger.Logger.Info().Msg("giredore server is ready")
// CTRL+C handler.
signalHandler := make(chan os.Signal, 1)
shutdownDone := make(chan bool, 1)
2019-10-16 23:32:21 +05:00
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
2019-10-16 23:32:21 +05:00
go func() {
<-signalHandler
httpserver.Shutdown()
configuration.Shutdown()
shutdownDone <- true
}()
<-shutdownDone
os.Exit(0)
}