Gracefully stops on SIGTERM

This commit is contained in:
Mildred Ki'Lya 2016-12-02 09:55:51 +01:00 committed by Mitchell Hashimoto
parent 4ab5356ff9
commit 9ab7cab19e
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 20 additions and 1 deletions

View File

@ -223,7 +223,7 @@ func makeShutdownCh() <-chan struct{} {
resultCh := make(chan struct{})
signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, os.Interrupt)
signal.Notify(signalCh, interruptSignals...)
go func() {
for {
<-signalCh

10
signal_unix.go Normal file
View File

@ -0,0 +1,10 @@
// +build !windows
package main
import (
"os"
"syscall"
)
var interruptSignals []os.Signal = []os.Signal{os.Interrupt, syscall.SIGTERM}

9
signal_windows.go Normal file
View File

@ -0,0 +1,9 @@
// +build windows
package main
import (
"os"
)
var interruptSignals []os.Signal = []os.Signal{os.Interrupt}