aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kiryukhin <alexander@kiryukhin.su>2019-04-04 10:15:18 +0300
committerAlexander Kiryukhin <alexander@kiryukhin.su>2019-04-04 10:15:18 +0300
commitc86dd5f3d70d310a26da73ee4ef2897121c18909 (patch)
tree214132f97bcc4eed30d8603deed344ad89f97c1f
parent73b65fc197971415a40b6dbae243c88c731cda83 (diff)
Fixed:v0.4.1
- ListenOsSignal handler now not in waitgroup. Before if all routines exited by itself (with DoNothingIfDone or DoNothingIfFail policies) waitgroup waits OS listener to complete
-rwxr-xr-xrutina.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/rutina.go b/rutina.go
index 256bce0..f04ff55 100755
--- a/rutina.go
+++ b/rutina.go
@@ -117,17 +117,17 @@ func (r *Rutina) ListenOsSignals(signals ...os.Signal) {
if len(signals) == 0 {
signals = []os.Signal{syscall.SIGINT, syscall.SIGTERM}
}
- r.Go(func(ctx context.Context) error {
+ go func() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, signals...)
r.log("starting OS signals listener")
select {
case s := <-sig:
r.log("stopping by OS signal (%v)", s)
- case <-ctx.Done():
+ r.Cancel()
+ case <-r.ctx.Done():
}
- return nil
- }, ShutdownIfDone, ShutdownIfFail)
+ }()
}
// Wait all routines and returns first error or nil if all routines completes without errors