diff --git a/core/app.go b/core/app.go index 834b9faf..e5e1e21d 100644 --- a/core/app.go +++ b/core/app.go @@ -97,10 +97,10 @@ func getEnvVarNameFromService(service string) string { // Run starts the application and blocks until finished func (a *App) Run() { + a.handleSignals() for { a.Bus = events.NewEventBus() a.ControlServer.Run(a.Bus) - a.handleSignals() a.handlePolling() if !a.Bus.Wait() { if a.StopTimeout > 0 { diff --git a/events/timer.go b/events/timer.go index 8d3b1deb..fa555089 100644 --- a/events/timer.go +++ b/events/timer.go @@ -41,18 +41,18 @@ func NewEventTimer( ) { go func() { ticker := time.NewTicker(tick) + // sending the timeout event potentially races with a closing + // rx channel, so just recover from the panic and exit + defer func() { + if r := recover(); r != nil { + return + } + }() for { select { case <-ctx.Done(): return case <-ticker.C: - // sending the timeout event potentially races with a closing - // rx channel, so just recover from the panic and exit - defer func() { - if r := recover(); r != nil { - return - } - }() rx <- Event{Code: TimerExpired, Source: name} } }