Skip to content

fix(standalone): auto-detect standalone mode for stop/kill/restart#2176

Open
odaneau-astro wants to merge 2 commits into
mainfrom
worktree-fix-standalone-stop-kill-2175
Open

fix(standalone): auto-detect standalone mode for stop/kill/restart#2176
odaneau-astro wants to merge 2 commits into
mainfrom
worktree-fix-standalone-stop-kill-2175

Conversation

@odaneau-astro

@odaneau-astro odaneau-astro commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves how --standalone mode to match expected behavior as follows:
If a user runs astro dev start --standalone, they expect astro dev stop/kill/restart to just work without having to re-specify --standalone for each command. Today, if I attempt to astro dev kill on standalone without the argument, nothing happens. From a user standpoint, their "dev" session started in standalone mode; it's normal to expect it to continue in that mode.
This PR switches the default behavior of the commands to account for it by auto-detecting if a standalone process is running.
Also, for astro dev restart, it should restart with --standalone mode by default for the same reason.

When using the --standalone argument, it also informs the user that they can set standalone mode permanently by running astro config set -g dev.mode standalone.

Original callout here: https://github.com/astronomer/docs/pull/6820#issuecomment-4711066875

Fixes #2175

  • Auto-detect standalone mode: resolveDevMode() now checks for a live standalone PID file (.astro/standalone/airflow.pid) when no explicit --standalone/--docker flag is set and the config is the default "docker". This means astro dev stop, astro dev kill, astro dev restart, astro dev ps, and astro dev logs all work automatically after astro dev start --standalone — no need to re-specify the flag.
  • Config hint: When --standalone is passed explicitly, a tip is shown suggesting astro config set -g dev.mode standalone to make it the default permanently.
  • Mode-switch safety: When --docker is explicitly passed while a standalone process is running, the standalone process is stopped automatically before proceeding. This prevents zombie standalone processes when switching modes.
  • Flag override: The --docker flag still takes priority over auto-detection, so users can force Docker mode even when a standalone process is running.

How it works

Priority order for mode resolution:

  1. --standalone flag → standalone
  2. --docker flag → docker (+ stops any running standalone process)
  3. Config dev.mode value (if not default "docker") → that value
  4. NEW: Live standalone PID file detected → standalone
  5. Default → docker

Test plan

  • Added test: auto-detects standalone when PID file has a live process
  • Added test: no auto-detect when PID file is missing
  • Added test: no auto-detect when PID file has a dead process
  • Added test: --docker flag overrides auto-detection
  • Added test: config set to "standalone" skips auto-detection (returns standalone directly)
  • Added test: --docker stops standalone process when switching modes
  • Added test: no-op when --docker set but no standalone running
  • Added test: no-op when standalone running but --docker not set
  • All 181 cmd tests pass (no regressions)

🤖 Generated with Claude Code

…2175)

When a project was started with `astro dev start --standalone`, the
stop/kill/restart commands required re-specifying `--standalone` to work.
This happened because `resolveDevMode()` defaulted to "docker" when no
flag was set.

Now `resolveDevMode()` checks for a live standalone PID file when no
explicit flag or config override is present, so commands like
`astro dev stop` automatically target the running standalone process.

Also adds a tip when `--standalone` is used explicitly, suggesting
`astro config set -g dev.mode standalone` to make it permanent.

Closes #2175

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@odaneau-astro odaneau-astro requested a review from a team as a code owner June 17, 2026 11:49
@coveralls-official

coveralls-official Bot commented Jun 17, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27687135351

Coverage increased (+0.02%) to 45.114%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (28 of 32 lines covered, 87.5%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
cmd/airflow.go 32 28 87.5%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 56401
Covered Lines: 25445
Line Coverage: 45.11%
Coverage Strength: 8.0 hits per line

💛 - Coveralls

…de switch

When a user explicitly passes --docker while a standalone process is
running, stop the standalone process first to prevent a zombie. This
runs early in the PersistentPreRunE chain so any subsequent docker
command starts clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

standalone project cannot be stopped

1 participant