Add support for SIGINT (#30)

Closes #28.
This commit is contained in:
Alexandre Fiori 2016-09-26 19:17:15 -04:00 committed by Naitik Shah
parent 2fe6ef9ad6
commit 5729e48447

View File

@ -98,12 +98,12 @@ func (a *app) term(wg *sync.WaitGroup) {
func (a *app) signalHandler(wg *sync.WaitGroup) { func (a *app) signalHandler(wg *sync.WaitGroup) {
ch := make(chan os.Signal, 10) ch := make(chan os.Signal, 10)
signal.Notify(ch, syscall.SIGTERM, syscall.SIGUSR2) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2)
for { for {
sig := <-ch sig := <-ch
switch sig { switch sig {
case syscall.SIGTERM: case syscall.SIGINT, syscall.SIGTERM:
// this ensures a subsequent TERM will trigger standard go behaviour of // this ensures a subsequent INT/TERM will trigger standard go behaviour of
// terminating. // terminating.
signal.Stop(ch) signal.Stop(ch)
a.term(wg) a.term(wg)