summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/main.go b/main.go
index dc50251..db58eca 100644
--- a/main.go
+++ b/main.go
@@ -11,6 +11,7 @@ import (
"os"
"os/signal"
"sync"
+ "syscall"
)
var globalConfig *GlobalConfig
@@ -131,14 +132,24 @@ func main() {
go recording.RunTask(ctx, &wg, &task)
}
- // listen Ctrl-C
- chSigInt := make(chan os.Signal)
- signal.Notify(chSigInt, os.Interrupt)
+ // listen on stop signals
+ chSigStop := make(chan os.Signal)
+ signal.Notify(chSigStop,
+ syscall.SIGHUP,
+ syscall.SIGINT,
+ syscall.SIGTERM)
go func() {
- <-chSigInt
+ <-chSigStop
cancelTasks()
}()
+ chSigQuit := make(chan os.Signal)
+ signal.Notify(chSigQuit, syscall.SIGQUIT)
+ go func() {
+ <-chSigQuit
+ os.Exit(0)
+ }()
+
// block main goroutine on task goroutines
wg.Wait()
}