fix(cmd): keep app context alive for graceful pack shutdown#345
Open
skhaz wants to merge 1 commit into
Open
Conversation
skhaz
commented
Jun 15, 2026
| } | ||
|
|
||
| waitForShutdownSignal(sigChan, logger, cancel) | ||
| waitForShutdownSignal(sigChan, logger, nil) |
Member
Author
There was a problem hiding this comment.
Don't cancel appCtx on the signal — it pre-empts the graceful stop. Let shutdown.Perform run first; defer cancel() cleans up after.
wolfy-j
approved these changes
Jun 15, 2026
Why: Running a hub module or pack (`wippy run <module>`) logged "failed to stop controllers during shutdown: supervisor is stopped: context canceled" and abandoned services instead of stopping them gracefully on exit. What: runPackEntries passed the appCtx cancel func as the first-signal callback, so the shutdown signal cancelled the context the supervisor and all its controllers derive from before shutdown.Perform ran the graceful stop, making every controller.Stop() short-circuit. Pass nil instead, matching the server path in run.go; the existing deferred cancel still tears down appCtx after shutdown completes. Adds a regression test that registers a running service and asserts graceful stop on signal.
54cf327 to
c5b4dbb
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.
Why
wippy run <hub-module>(and.wapppack files) loggedfailed to stop controllers during shutdown: supervisor is stopped: context canceledon exit and abandoned services instead of stopping them gracefully.
What
The pack runner (
runPackEntries) passed theappCtxcancel func as thefirst-signal callback, so the shutdown signal cancelled the context the
supervisor and all its controllers derive from before
shutdown.Performran the graceful stop — making every
controller.Stop()short-circuit. Passnilinstead, matching the server path inrun.go. The existingdefer cancel()still tears downappCtxafter shutdown completes.Testing
make test— 292 packages, 0 failures;golangci-lintv2.8.0 — 0 issues.TestRunPackEntries_GracefulShutdownStopsRunningService(
-race,-count=5, no flakes): fails when reverted tocancel, passes withnil.run_pack.go: 36 killed, 0 lived, 100% efficacy.kickside/kickside,keeper/keeper,userspace/users): shutdown "supervisor is stopped" errors 3 → 0; servicesnow log clean graceful stop.