fix(dapi): use signal.NotifyContext for graceful shutdown#969
Open
Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Open
fix(dapi): use signal.NotifyContext for graceful shutdown#969Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Mayveskii wants to merge 1 commit intogonka-ai:mainfrom
Conversation
Collaborator
|
Tiny useful fix. Please rebase |
The root context was created with context.WithCancel(context.Background()) which is only cancelled when cancel() is called explicitly (i.e. on normal function return). Sending SIGTERM (e.g. docker stop, systemctl stop) killed the process immediately via SIGKILL after timeout, bypassing the deferred config flush and other cleanup. Replace with signal.NotifyContext so SIGTERM/SIGINT propagate through the context tree: all goroutines using ctx observe cancellation and shut down cleanly, and the config flush at <-ctx.Done() actually runs.
3dec289 to
8c00fa3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Root context uses context.WithCancel which SIGTERM does not cancel. Config flush never runs on docker stop.
Fix
Replace with signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) so SIGTERM/SIGINT propagate through context tree.
Impact: config reliably flushed on shutdown, zero change on happy path