From b18612942fc5d9fdf9916d8b8f0e9383c6b5c293 Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Mon, 19 Apr 2021 15:06:22 -0700 Subject: [PATCH] Fixes shutdown signal --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index f9ceb503..94d2bcf9 100644 --- a/main.go +++ b/main.go @@ -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)