Repository navigation
feat: a service's stop command runs when devstack stops an instance (ADR-0059) - #247
Merged
Merged
Conversation
…d outside its process tree (Proposed) A `docker run` service leaves its container running whenever the CLI ends without the container: a process that ignores the graceful signal (killed after the timeout), a CLI killed on its own, a failed start, a dead daemon. Measured on Windows: the graceful stop does reach the container (the CLI forwards CTRL_BREAK as SIGINT; with `--init` the container is gone at once), but `sleep` as PID 1 ignores it. The ADR proposes `[services.<name>] stop`: a command expanded with the instance's placeholders when it starts, run whenever the instance ends, before the graceful signal, bounded and never blocking the stop; recorded in state.json so the next start runs it after a crash. Refs #245 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ADR-0059)
`[services.<name>] stop` is expanded with the instance's placeholders when
it starts (its `{port}`, `{lane_suffix}`, as `run`) and runs whenever the
instance ends: a stop, a restart, `down`, the old instance a candidate
replaced, a start or candidate that failed, a job done, an instance that
ended by itself. It runs before the graceful signal, at most 30 s, its
output appended to the instance's log; a failure is logged and the stop
goes on (ADR-0009). Every end of an instance now goes through one place,
`Supervisor::end`.
The expanded command, its directory and the instance's log are recorded in
state.json beside the cleanup record (ADR-0016); the next start of the
tree's supervisor runs the recorded ones before anything starts, with
devstack's own environment (the service's is not written to disk).
A profile may set `stop`; `kind = "static"` has none, and a profile that
makes a service static drops it; hot-reload mode does not use it.
`devstack check` warns about `stop` without `requires = "0.21.0"`.
docs/stack-file.md describes a container as a service (`--init`, `--rm`, a
name per instance, `stop`); the devstack-config skill says the same.
Refs #245
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7schmiede
force-pushed
the
feat/service-stop
branch
from
October 23, 2026 16:13
f2b9481 to
a0ddf2f
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.
Summary
[services.<name>] stopends what a service'srunstarted outside its process tree, a container of adocker runservice, say.{port}is the instance's own,{lane_suffix}, … as forrun). It runs whenever the instance ends: a stop, a restart,down, the old instance a candidate replaced, a failed or cancelled start/candidate, a finished job, or an instance that ended by itself.Supervisor::end.state.jsonbeside the ADR-0016 cleanup record. The next start of that tree's supervisor runs the recorded ones before anything starts. They run with devstack's own environment, because the service's environment can hold secrets and is not written to disk.stop.kind = "static"has none, and a profile that makes a service static drops it. Hot-reload mode does not use it.devstack checkwarns when a file usesstopwithoutrequires = "0.21.0".docs/stack-file.mdhas a section on a container as a service (--init,--rm, a name with{lane_suffix}-{port},stop). The devstack-config skill and the changelog are updated too.The measurement behind it (#245)
devstack 0.20.0, Windows 11, Docker Desktop 29.9.2:
rundevstack stopdocker run --rm alpine sleep 300Updocker run --rm --init alpine sleep 300devstack down)stop = "docker rm -f <name>"(this branch)The graceful stop does reach the container:
CTRL_BREAKgoes to the process group, and the CLI forwards it asSIGINT. In the issue's examplesleepis PID 1 and ignores that signal. Whatstopadds is cover for the cases the signal cannot reach: a process that ignores it, a CLI that ended by itself, a failed start, and a dead daemon.Test plan
cargo fmt,cargo clippy --all-targetscleancargo test -p devstack-config -p devstack-daemon -p devstack-skills -p devstack-proc -p devstacka_services_stop_ends_what_its_run_started(daemon integration, no SDK): the stop gets the instance's port and writes into its log, and after a hard kill of the daemon the nextupruns the recorded stop. Passed on Windows, together witha_hanging_job_or_step_ends,a_service_that_exits_by_itself_comes_back,a_stop_while_the_migrator_runs_holds,a_failed_first_start_restores_again,edits_become_candidates,a_job_runs_once_for_two_candidatesandserving_without_workers_stays_visible.stop.Refs #245
🤖 Generated with Claude Code