From 1772990500c97a79adce15c73919339d6e1618d7 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Mon, 1 Apr 2019 11:38:03 +0300 Subject: Options to listen different signals --- go.mod | 2 -- rutina.go | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 825fff3..e827eb1 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1 @@ module github.com/neonxp/rutina - -go 1.12 diff --git a/rutina.go b/rutina.go index 0bdc7e8..703e9fc 100755 --- a/rutina.go +++ b/rutina.go @@ -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 { -- cgit v1.2.3