Skip to content

Graceful shutdown on SIGTERM caused by manual app stop#703

Open
lmagyar wants to merge 1 commit into
hassio-addons:mainfrom
lmagyar:pr-sigterm
Open

Graceful shutdown on SIGTERM caused by manual app stop#703
lmagyar wants to merge 1 commit into
hassio-addons:mainfrom
lmagyar:pr-sigterm

Conversation

@lmagyar

@lmagyar lmagyar commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Proposed Changes

This is to prevent showing "Error" app status after plain manual app stop.

Finish scripts in pending PRs #667 #680 are also modified.

Related Issues

Summary by CodeRabbit

  • Bug Fixes
    • Improved service termination and exit code handling across multiple background services to ensure proper shutdown behavior under specific conditions.

@lmagyar lmagyar added bugfix Inconsistencies or issues which will cause a problem for users or implementors. no-stale This issue or PR is exempted from the stable bot. labels Jun 16, 2026
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Five S6 finish scripts (nginx, share-homeassistant, taildrop, tailscaled, web) each receive an identical one-line change: the inner condition inside the exit_code_service == 256 branch now additionally requires exit_code_signal != 15 before writing the computed 128 + exit_code_signal halt exit code.

Changes

Signal 15 guard in S6 finish scripts

Layer / File(s) Summary
Add exit_code_signal != 15 guard to exit_code_service == 256 branch
tailscale/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish, tailscale/rootfs/etc/s6-overlay/s6-rc.d/share-homeassistant/finish, tailscale/rootfs/etc/s6-overlay/s6-rc.d/taildrop/finish, tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/finish, tailscale/rootfs/etc/s6-overlay/s6-rc.d/web/finish
All five finish scripts tighten line 18: the exit_code_service == 256 path now writes the computed halt exit code only when exit_code_signal != 15 in addition to exit_code_container == 0. Previously the signal value was not checked.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A signal of fifteen means "please stop, be nice,"
No need to cry wolf or exit code splice.
Five scripts now agree: if SIGTERM's the call,
We quietly finish and don't fuss at all.
Hop hop, clean shutdown — no panic, no strife! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change across all modified files: adding signal-based conditions to graceful shutdown handling for SIGTERM signals in finish scripts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tailscale/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish`:
- Line 18: Three finish scripts are missing the SIGTERM guard (`-ne 15`) that
prevents writing signal-based exit codes when services are manually stopped. In
the protect-subnets/finish, magicdns-egress-proxy/finish, and
magicdns-ingress-proxy/finish scripts, locate the condition that checks
`exit_code_container` and update it to include the `exit_code_signal -ne 15`
check alongside the existing `exit_code_container -eq 0` check, matching the
pattern already correctly implemented in nginx/finish and other scripts. This
ensures all services consistently skip writing exit codes on SIGTERM signals.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c0d145b-8535-4e9c-b700-ea5dcce850e9

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8b8c5 and fbc7285.

📒 Files selected for processing (5)
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/share-homeassistant/finish
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/taildrop/finish
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/finish
  • tailscale/rootfs/etc/s6-overlay/s6-rc.d/web/finish

Comment thread tailscale/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Inconsistencies or issues which will cause a problem for users or implementors. no-stale This issue or PR is exempted from the stable bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant