Alter graceful shutdown to be compatible with Docker

This commit is contained in:
akp 2024-03-31 23:07:18 +01:00
parent 8fcde54067
commit a24a333e4a
No known key found for this signature in database
GPG key ID: CF8D58F3DEB20755
2 changed files with 4 additions and 8 deletions

View file

@ -38,7 +38,7 @@ func run() error {
platform.StartCron()
shutdownSig := make(chan os.Signal)
signal.Notify(shutdownSig, syscall.SIGINT)
signal.Notify(shutdownSig, syscall.SIGINT, syscall.SIGTERM)
wg := new(sync.WaitGroup)
httpServer := platform.NewServer(conf.HTTP.Address())
@ -52,7 +52,7 @@ func run() error {
platform.StopCron()
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*2)
defer cancel()
if err := httpServer.Shutdown(ctx); err != nil {
slog.Error("http server did not shutdown correctly", "error", err)

View file

@ -45,12 +45,8 @@ func init() {
func NewServer(address string) *http.Server {
return &http.Server{
Addr: address,
Handler: http.HandlerFunc(handler),
ReadTimeout: 10,
ReadHeaderTimeout: 10,
WriteTimeout: 10,
IdleTimeout: 10,
Addr: address,
Handler: http.HandlerFunc(handler),
}
}