Skip to content

fix(configure): free the terminal on finish / Ctrl+C (stop event + signals)#111

Merged
hyoshi merged 2 commits into
mainfrom
fix/configure-graceful-shutdown
May 17, 2026
Merged

fix(configure): free the terminal on finish / Ctrl+C (stop event + signals)#111
hyoshi merged 2 commits into
mainfrom
fix/configure-graceful-shutdown

Conversation

@hyoshi
Copy link
Copy Markdown
Collaborator

@hyoshi hyoshi commented May 17, 2026

Problem

mureo configure busy-slept for a fixed --timeout-seconds (default 600s) with no signal handler and no completion trigger. Closing the browser left the terminal hung for up to 10 minutes; Ctrl+C did not work.

Fix

  • ConfigureWizard: stop_event + request_stop()
  • run_configure_wizard: install SIGINT/SIGTERM handlers (set the event), wait on the event instead of busy-sleeping, restore prior handlers + graceful shutdown in finally; timeout_seconds is now only a hard cap
  • POST /api/shutdown (Host + CSRF gated like every POST) → request_stop
  • Completed step: a "Finish & free the terminal" button (EN/JA) that POSTs /api/shutdown
  • --timeout-seconds help reworded (it was never "inactivity")

Verification

  • Real subprocess: SIGINT 0.23s / SIGTERM 0.25s graceful exit (was: hang up to 600s)
  • Real Chrome tab loaded the configure SPA; the button's exact MUREO.postJson('/api/shutdown') (same-origin, real CSRF) → terminal freed in 0.09s, response {ok:true,{status:stopping}}
  • pytest 3212 passed in a clean env (3 new lifecycle tests); ruff/black/JS/i18n-parity clean
  • code-reviewer APPROVE (no CRITICAL/HIGH)
  • Confirmed PyPI 0.9.0 lacks the route (404) → bug is real

hyoshi added 2 commits May 17, 2026 12:25
…gnals)

mureo configure busy-slept for a fixed --timeout-seconds (default
600s) with no signal handler and no completion trigger, so closing
the browser left the terminal hung up to 10 min and Ctrl+C was
unreliable.

- ConfigureWizard gains stop_event + request_stop()
- run_configure_wizard installs SIGINT/SIGTERM handlers (set the
  stop event), waits on the event instead of busy-sleeping, restores
  prior handlers + graceful shutdown in finally; timeout_seconds is
  now only a hard cap
- POST /api/shutdown (Host+CSRF gated like every POST) -> request_stop
- completed step gets a 'Finish & free the terminal' button (EN/JA)
  that POSTs /api/shutdown
- --timeout-seconds help reworded (it was never 'inactivity')

Verified: real subprocess SIGINT 0.23s / SIGTERM 0.25s graceful
exit; real Chrome tab loading the configure SPA + the button's
exact MUREO.postJson('/api/shutdown') call -> terminal freed in
0.09s, response {ok:true,{status:stopping}}; pytest 3212 passed in
a clean env (3 new lifecycle tests); PyPI 0.9.0 lacks the route
(404) confirming the bug is real.

Test plan:
- [x] full suite 3212 passed (clean env); ruff/black/JS/i18n parity
- [x] code-reviewer APPROVE (no CRITICAL/HIGH)
- [x] real browser + real signal end-to-end verification
…ure_wizard

CI lint (mypy mureo/ --ignore-missing-imports) flagged server.py:212:
the loop var `sig` was reused (Signals from the install loop vs int
from the dict.items() restore loop). Store handlers in a
list[tuple[int, object]] and use a distinct `signum` in the restore
loop. Type-only; behavior identical (code-reviewer APPROVE).
@hyoshi hyoshi merged commit f6a3c39 into main May 17, 2026
8 checks passed
@hyoshi hyoshi deleted the fix/configure-graceful-shutdown branch May 17, 2026 03:35
@hyoshi hyoshi mentioned this pull request May 18, 2026
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.

1 participant