diff options
-rw-r--r-- | go.mod | 2 | ||||
-rwxr-xr-x | rutina.go | 7 |
2 files changed, 5 insertions, 4 deletions
@@ -1,3 +1 @@ module github.com/neonxp/rutina - -go 1.12 @@ -122,10 +122,13 @@ func (r *Rutina) Go(doer func(ctx context.Context) error, opts ...Options) { } // OS signals handler -func (r *Rutina) ListenOsSignals() { +func (r *Rutina) ListenOsSignals(signals ...os.Signal) { + if len(signals) == 0 { + signals = []os.Signal{os.Kill, os.Interrupt} + } r.Go(func(ctx context.Context) error { sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt, os.Kill) + signal.Notify(sig, signals...) select { case s := <-sig: if r.logger != nil { |