Skip to content

Commit 9e3b3f9

Browse files
committed
log caught signal and reaction
1 parent 240e09f commit 9e3b3f9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

exit/listen.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,17 @@ func Listen(fn func(os.Signal)) {
3030
var sig os.Signal
3131
select {
3232
case sig = <-sigchan:
33-
if sig == syscall.SIGHUP {
33+
switch sig {
34+
case syscall.SIGHUP:
35+
log.Print("[INFO] Caught SIGHUP. Ignoring")
3436
continue
37+
case os.Interrupt:
38+
log.Print("[INFO] Caught SIGINT. Exiting")
39+
case syscall.SIGTERM:
40+
log.Print("[INFO] Caught SIGTERM. Exiting")
41+
default:
42+
// fallthrough in case we forgot to add a switch clause.
43+
log.Printf("[INFO] Caught signal %v. Exiting", sig)
3544
}
3645
case <-quit:
3746
}

0 commit comments

Comments
 (0)