Migrate to go.mod

This commit is contained in:
uditaren 2024-04-11 11:07:26 +02:00
parent 0fc1a7f846
commit e6fe1b3e0c
3 changed files with 22 additions and 8 deletions

View File

@ -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.

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module udico.de/util/terminator
go 1.22.1

View File

@ -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 (
"os"
"os"
"os/signal"
"syscall"
)
// enable to react to
// <-terminator.Terminate
//
// <-terminator.Terminate
//
// nicely
var Terminate = make(chan struct{})
func init() {
sigs := make(chan os.Signal)
signal.Notify(sigs, os.Interrupt, os.Kill)
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