2019-10-05 21:53:22 +05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
2019-10-13 15:12:54 +05:00
|
|
|
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"
|
2019-10-05 21:53:22 +05:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-10-05 21:53:22 +05:00
|
|
|
signal.Notify(signalHandler, os.Interrupt, syscall.SIGTERM)
|
2019-10-16 23:32:21 +05:00
|
|
|
|
2019-10-05 21:53:22 +05:00
|
|
|
go func() {
|
|
|
|
<-signalHandler
|
|
|
|
httpserver.Shutdown()
|
2019-10-07 18:21:26 +05:00
|
|
|
configuration.Shutdown()
|
2019-10-05 21:53:22 +05:00
|
|
|
shutdownDone <- true
|
|
|
|
}()
|
|
|
|
|
|
|
|
<-shutdownDone
|
|
|
|
os.Exit(0)
|
|
|
|
}
|