Skip to content

speech_to_phrase: Shut down cleanly on stop - #4800

Merged
agners merged 3 commits into
home-assistant:masterfrom
agners:speech-to-phrase-clean-shutdown
Aug 27, 2026
Merged

speech_to_phrase: Shut down cleanly on stop#4800
agners merged 3 commits into
home-assistant:masterfrom
agners:speech-to-phrase-clean-shutdown

Conversation

@agners

@agners agners commented Aug 25, 2026

Copy link
Copy Markdown
Member

What this PR changes

  1. Shut down cleanly on stop: adds an s6 down-signal file so the speech-to-phrase service is stopped with SIGINT instead of SIGTERM.
  2. Leave "Starting" faster: the healthcheck now probes readiness every 5 s during startup (--start-interval=5s, normal interval stays 30 s).
  3. Bumps the app to 1.4.5.

Background

Clean shutdown: speech-to-phrase installs no SIGTERM handler, so on stop the process dies from the default signal action and the container exits with code 143, which newer Supervisor versions flag:

App Speech-to-Phrase did not handle SIGTERM and was terminated by the default signal handler (exit code 143).

It does, however, catch KeyboardInterrupt around its asyncio entrypoint — so SIGINT produces a clean exit 0 today, no upstream change required. s6-rc's down-signal file makes s6 deliver SIGINT on service stop. Verified against the real s6 init in the built image: docker stop completes in ~3 s, s6 logs "service speech-to-phrase successfully stopped", and the container exit code is 0 (previously 143).

Faster startup detection: the app only opens its Wyoming port after the initial training pass, and with the default 30 s healthcheck interval it could sit in "Starting" for half a minute after it was already serving. With --start-interval=5s the built image reports healthy 8 s after container start (including forced training), down from up to ~40 s. Requires Docker Engine ≥ 25 (HAOS ships well past that) and hadolint ≥ v2.14 in CI — see #4802, which should merge first.

Longer term, a SIGTERM handler in python-wyoming's AsyncServer fixes all Wyoming apps at once — submitted as OHF-Voice/wyoming#55; the down-signal makes this app well-behaved now and becomes redundant-but-harmless once that ships. Companion PR for Whisper: #4801.

🤖 Generated with Claude Code

speech-to-phrase has no SIGTERM handler, so s6's default SIGTERM kills
the process and the container exits with code 143, which newer
Supervisor versions flag as an unclean shutdown. It does catch
KeyboardInterrupt and exit 0 on SIGINT, so tell s6 to stop the
service with SIGINT via the down-signal file.

Verified with the full s6 init: docker stop completes in ~3s, the
service log shows a clean stop, and the container exits with code 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e764122-cad3-4116-a055-be3963889326

📥 Commits

Reviewing files that changed from the base of the PR and between 0d39f0e and 5483cad.

📒 Files selected for processing (2)
  • speech_to_phrase/CHANGELOG.md
  • speech_to_phrase/Dockerfile
🚧 Files skipped from review as they are similar to previous changes (1)
  • speech_to_phrase/CHANGELOG.md

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The add-on version changes to 1.4.5. Startup health checks run every 5 seconds before switching to 30-second checks. The s6 service sends SIGINT during shutdown. The changelog records the startup readiness change.

Changes

Speech-to-phrase runtime updates

Layer / File(s) Summary
Startup readiness checks
speech_to_phrase/Dockerfile, speech_to_phrase/config.yaml, speech_to_phrase/CHANGELOG.md
The Docker healthcheck uses a 5-second startup interval before switching to the existing 30-second interval. The add-on version changes to 1.4.5. The changelog records the startup readiness update.
Service shutdown signaling
speech_to_phrase/rootfs/etc/s6-overlay/s6-rc.d/speech-to-phrase/down-signal
The s6 service sends SIGINT to the speech-to-phrase process during shutdown.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 5483c

The service now stops with SIGINT for a clean exit, with the app version updated accordingly; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: configuring the speech-to-phrase service to shut down cleanly when stopped.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

With the default 30s healthcheck interval the app can sit in the
"Starting" state for half a minute after it is already serving. Use
--start-interval=5s so readiness is detected within seconds once
training completes and the Wyoming port opens.

Verified: container reports healthy 8s after start (including forced
training), down from up to ~40s.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@agners
agners requested review from sairon and a balanced review from Copilot August 27, 2026 09:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds clean shutdown behavior and faster startup readiness detection for Speech-to-Phrase.

Changes:

  • Sends SIGINT when stopping the s6 service.
  • Probes readiness every five seconds during startup.
  • Bumps the app version to 1.4.5 and updates the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
speech_to_phrase/rootfs/etc/s6-overlay/s6-rc.d/speech-to-phrase/down-signal Configures clean SIGINT shutdown.
speech_to_phrase/Dockerfile Adds the startup healthcheck interval.
speech_to_phrase/config.yaml Bumps the app version.
speech_to_phrase/CHANGELOG.md Documents the release changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@agners
agners merged commit ae21782 into home-assistant:master Aug 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants