diff options
Diffstat (limited to 'src/main.go')
-rw-r--r-- | src/main.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main.go b/src/main.go index 6a1a118..0c3479d 100644 --- a/src/main.go +++ b/src/main.go @@ -3,10 +3,13 @@ package main import ( "fmt" "log" - "net/http" + "os" + "os/signal" "strings" + "syscall" "git.darknebu.la/emile/corona-metrics/src/structs" + "git.darknebu.la/emile/corona-metrics/src/http" "github.com/sirupsen/logrus" "github.com/spf13/viper" ) @@ -65,3 +68,13 @@ func initLogging() { } } + +// ExitHandler handles exit signals such as ^C +func ExitHandler() { + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + go func() { + <-c + os.Exit(1) + }() +} |