feat(shutdown): handle SIGTERM for k8s graceful shutdown#594
Merged
thepagent merged 1 commit intoopenabdev:mainfrom Apr 27, 2026
Merged
feat(shutdown): handle SIGTERM for k8s graceful shutdown#594thepagent merged 1 commit intoopenabdev:mainfrom
thepagent merged 1 commit intoopenabdev:mainfrom
Conversation
thepagent
approved these changes
Apr 27, 2026
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
shutdown_signal()helper insrc/main.rsthat waits for SIGINT or SIGTERM on unix and falls back to ctrl_c on Windows.tokio::signal::ctrl_c().await.ok()call sites with the helper so Kubernetes-style SIGTERM triggers the full cleanup path (Discord shard manager → Slack/gateway shutdown channel → ACP pool drain → child process group SIGTERM/SIGKILL escalation).Fixes #593.
Discord discussion: https://discord.com/channels/1491295327620169908/1491365157010542652/1498213613410848789
Why
tokio::signal::ctrl_c()only catches SIGINT. Kubernetes sends SIGTERM to PID 1 during pod termination, so the previous code skipped graceful cleanup and got SIGKILL'd afterterminationGracePeriodSeconds.Relationship to #449
#449 added
tinias PID 1 in the Dockerfiles, which ensures SIGTERM is delivered to openab (and reaps agent-grandchild zombies). This PR is the complementary second half: making openab handle the SIGTERM that tini forwards. Without this change, SIGTERM still hit the default disposition (terminate without running cleanup) even with tini in place.Test plan
cargo clippy --all-targets -- -D warningscargo test --bin openab(124 passed)kill -TERM <pid>against a running openab process and confirm "shutdown signal received" → "openab shut down" in logs.🤖 Generated with Claude Code