-
Notifications
You must be signed in to change notification settings - Fork 314
Closed
Description
Describe the bug
Regression: It's impossible to shutdown from an OS signal after startCtx
is Done()
.
To Reproduce
- Start an fx app
- Wait
startTimeout
(default is 15s). - Send SIGTERM to the process
- Nothing will handle the signal and the app will not shut down
Expected behavior
The apps shut down correctly like it did in the previous release.
Additional context
This line starts the goroutine that dispatches os signals.
Line 118 in 213eb86
go recv.relayer(ctx) |
The goroutine then blocks on
Lines 82 to 95 in 213eb86
func (recv *signalReceivers) relayer(ctx context.Context) { | |
defer func() { | |
recv.finished <- struct{}{} | |
}() | |
select { | |
case <-recv.shutdown: | |
return | |
case <-ctx.Done(): | |
return | |
case signal := <-recv.signals: | |
recv.Broadcast(ShutdownSignal{ | |
Signal: signal, | |
}) |
After the startCtx
is Done()
, this goroutine exits and thus there's nothing to process OS signals to initiate shutdown.
Replacing the goroutine invocation by go recv.relayer(context.TODO())
fixed the issue for me. The context passed here should not be Done()
until the application stops.
tunhvn and phongphongg
Metadata
Metadata
Assignees
Labels
No labels