diff --git a/statecontext/innerState.go b/statecontext/innerState.go index 78c9151..7837203 100644 --- a/statecontext/innerState.go +++ b/statecontext/innerState.go @@ -16,7 +16,6 @@ func initState() *state { obj.ctx, obj.cancel = context.WithCancel(context.Background()) signal.Notify(obj.signChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) - go listenSignal() return obj } diff --git a/statecontext/stateContext.go b/statecontext/stateContext.go index 3651c0c..8fb53ac 100644 --- a/statecontext/stateContext.go +++ b/statecontext/stateContext.go @@ -25,6 +25,7 @@ var innerState *state = nil func InitState() { once.Do(func() { innerState = initState() + go listenSignal() }) }