73f77f1624
This makes systemd not put unit into fail mode when stopping INFO: * make sure to use signals.RegisterCloser for everything that should be closed on interrupt * for any net.Listeners created make sure to wrap them with network.WrapListener and register with signals.RegisterCloser
35 lignes
505 o
Go
35 lignes
505 o
Go
// +build win32
|
|
|
|
package signals
|
|
|
|
import (
|
|
"os"
|
|
"os/signal"
|
|
)
|
|
|
|
func Handle() {
|
|
// TODO: Something about SIGHUP for Windows
|
|
|
|
chnl := make(chan os.Signal)
|
|
signal.Notify(chnl, os.Interrupt)
|
|
for {
|
|
sig, ok := <-chnl
|
|
if !ok {
|
|
break
|
|
}
|
|
switch sig {
|
|
case os.Interrupt:
|
|
// this also closes listeners
|
|
interrupted()
|
|
return
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// win32 interrupt handler
|
|
// called in interrupted()
|
|
func handleInterrupt() {
|
|
// XXX: put any win32 specific cleanup here as needed
|
|
}
|