Migrate to go.mod
This commit is contained in:
parent
0fc1a7f846
commit
e6fe1b3e0c
|
@ -1,3 +1,5 @@
|
||||||
# terminator
|
terminator
|
||||||
|
==========
|
||||||
|
|
||||||
|
The terminator module provides a clean way to react to Ctrl-C, SIGTERM, etc.
|
||||||
|
|
||||||
The go way of handling ctrl-c, sigterm, etc.
|
|
|
@ -1,19 +1,28 @@
|
||||||
package terminator /* import "udico.de/uditaren/terminator" */
|
// Package terminator provides a simple way to await process termination.
|
||||||
|
//
|
||||||
|
// Just wait until the Terminate channel closes:
|
||||||
|
//
|
||||||
|
// <-terminator.Terminate
|
||||||
|
//
|
||||||
|
// it will fall through, once your process receives Ctrl-C, SIGINT, SIGTERM or SIGKILL signal.
|
||||||
|
package terminator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// enable to react to
|
// enable to react to
|
||||||
// <-terminator.Terminate
|
//
|
||||||
|
// <-terminator.Terminate
|
||||||
|
//
|
||||||
// nicely
|
// nicely
|
||||||
var Terminate = make(chan struct{})
|
var Terminate = make(chan struct{})
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
sigs := make(chan os.Signal)
|
sigs := make(chan os.Signal)
|
||||||
signal.Notify(sigs, os.Interrupt, os.Kill)
|
signal.Notify(sigs, os.Interrupt, os.Kill)
|
||||||
signal.Notify(sigs, syscall.SIGTERM)
|
signal.Notify(sigs, syscall.SIGTERM)
|
||||||
|
|
||||||
// When notified about SIGINT, SIGTERM, or SIGKILL close the Terminator channel
|
// When notified about SIGINT, SIGTERM, or SIGKILL close the Terminator channel
|
||||||
|
|
Loading…
Reference in New Issue
Block a user