]> git.jsancho.org Git - midgaard_bot.git/commitdiff
Clean exit when Ctrl+C arrives
authorJavier Sancho <jsf@jsancho.org>
Mon, 27 Nov 2017 16:29:57 +0000 (17:29 +0100)
committerJavier Sancho <jsf@jsancho.org>
Mon, 27 Nov 2017 16:29:57 +0000 (17:29 +0100)
midgaard_bot.go

index a11ab8af639d019d6993ebaf2d20e44663356e1d..26278aa61638ef4819cad77bd92c91c7e4a5fd7d 100644 (file)
@@ -21,6 +21,8 @@ package main
 import (
        "context"
        "log"
+       "os"
+       "os/signal"
 
        "github.com/jessevdk/go-flags"
 )
@@ -48,10 +50,9 @@ func main() {
                log.Panic(err)
        }
 
-       for {
-               select {
-               case <-ctx.Done():
-                       break
-               }
-       }
+       intChannel := make(chan os.Signal, 1)
+       signal.Notify(intChannel, os.Interrupt)
+       <-intChannel
+
+       log.Print("Exit")
 }