aboutsummaryrefslogtreecommitdiff
path: root/rutina.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-04-01 11:38:03 +0300
committerAlexander Kiryukhin <a.kiryukhin@corp.mail.ru>2019-04-01 11:38:03 +0300
commit1772990500c97a79adce15c73919339d6e1618d7 (patch)
tree8e3b7241c861c7944d3de383cda8fb5f4fed7109 /rutina.go
parentda95ae7f82849666eae1a19932a059d4870dcc31 (diff)
Options to listen different signalsv0.3.3
Diffstat (limited to 'rutina.go')
-rwxr-xr-xrutina.go7
1 files changed, 5 insertions, 2 deletions
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 {