1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-30 17:47:28 +01:00

Fixes shutdown signal

This commit is contained in:
Amir Raminfar
2021-04-19 15:06:22 -07:00
parent ddb0c05173
commit b18612942f

View File

@@ -4,11 +4,13 @@ import (
"context"
"embed"
"io/fs"
"net/http"
_ "net/http/pprof"
"net/url"
"os"
"os/signal"
"strings"
"syscall"
"time"
"github.com/alexflint/go-arg"
@@ -108,14 +110,14 @@ func main() {
go doStartEvent(args)
go func() {
log.Infof("Accepting connections on %s", srv.Addr)
if err := srv.ListenAndServe(); err != nil {
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
log.Fatal(err)
}
}()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, os.Kill)
signal.Notify(c, syscall.SIGTERM)
<-c
log.Info("Shutting down...")
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)