- service stop: fix race

Service Stop handler sends SIGINT to the main thread,
 which begins the stops the app.
This commit is contained in:
Simon Zolin
2019-07-02 12:56:23 +03:00
parent 5abf0b5a53
commit 131aa4c93c
3 changed files with 9 additions and 6 deletions

View File

@@ -99,10 +99,10 @@ func run(args options) {
requireAdminRights()
}
signalChannel := make(chan os.Signal)
signal.Notify(signalChannel, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
config.appSignalChannel = make(chan os.Signal)
signal.Notify(config.appSignalChannel, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
go func() {
<-signalChannel
<-config.appSignalChannel
cleanup()
cleanupAlways()
os.Exit(0)