Initial checkin
This commit is contained in:
parent
d49deafb31
commit
45d94a07a1
25
terminator.go
Normal file
25
terminator.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package terminator /* import "udico.de/uditaren/terminator" */
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// enable to react to
|
||||||
|
// <-terminator.Terminate
|
||||||
|
// nicely
|
||||||
|
var Terminate = make(chan struct{})
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
sigs := make(chan os.Signal)
|
||||||
|
signal.Notify(sigs, os.Interrupt, os.Kill)
|
||||||
|
signal.Notify(sigs, syscall.SIGTERM)
|
||||||
|
|
||||||
|
// When notified about SIGINT, SIGTERM, or SIGKILL close the Terminator channel
|
||||||
|
// in order to notify interested parties to quit.
|
||||||
|
go func(c <-chan os.Signal) {
|
||||||
|
<-c
|
||||||
|
close(Terminator)
|
||||||
|
}(sigs)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user