Skip to content

Add SIGINT/SIGTERM handlers for graceful and timely shutdown.#14

Merged
apognu merged 1 commit into
mainfrom
feat/signal-handlers
Jun 27, 2026
Merged

Add SIGINT/SIGTERM handlers for graceful and timely shutdown.#14
apognu merged 1 commit into
mainfrom
feat/signal-handlers

Conversation

@apognu

@apognu apognu commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added graceful shutdown behavior to the server when it receives interrupt or termination signals.
    • The server now stops accepting new work and can allow in-flight requests to complete more cleanly before exiting.

@apognu apognu requested a review from Pascal-Delange June 27, 2026 05:41
@apognu apognu self-assigned this Jun 27, 2026
@apognu apognu added the enhancement New feature or request label Jun 27, 2026
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@apognu, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 28 minutes and 17 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e87432ef-aa1b-4da7-be3b-ba03e50830ed

📥 Commits

Reviewing files that changed from the base of the PR and between 26f69fd and 882bc71.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .github/workflows/build.yml
  • .github/workflows/deploy.yml
  • .github/workflows/docker.yml
  • .github/workflows/production.yml
  • .github/workflows/staging.yml
  • Cargo.toml
  • src/main.rs
📝 Walkthrough

Walkthrough

The server now enables Tokio signal support, starts Axum with graceful shutdown, and awaits a new shutdown future that listens for SIGINT and SIGTERM.

Changes

Graceful shutdown

Layer / File(s) Summary
Server wiring
Cargo.toml, src/main.rs
tokio gains the signal feature, and main now starts Axum with with_graceful_shutdown(shutdown()).
Signal shutdown handler
src/main.rs
shutdown() installs Ctrl-C and SIGTERM handlers, then uses tokio::select! to resolve when either signal arrives and log it.

Sequence Diagram(s)

sequenceDiagram
  participant main
  participant Serve as "axum::serve(...).with_graceful_shutdown(shutdown())"
  participant Shutdown as "shutdown()"
  participant CtrlC as "tokio::signal::ctrl_c()"
  participant Terminate as "tokio::signal::unix::signal(SignalKind::terminate())"
  main->>Serve: start server
  Serve->>Shutdown: await shutdown()
  Shutdown->>CtrlC: listen for SIGINT
  Shutdown->>Terminate: listen for SIGTERM
  CtrlC-->>Shutdown: Ctrl-C received
  Terminate-->>Shutdown: SIGTERM received
  Shutdown-->>Serve: resolve
  Serve-->>main: exit
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

The server hears the winter wind at last,
And bows to SIGINT when shadows pass.
SIGTERM, too, finds a gentle lane,
While Axum sleeps and wakes not in vain.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding SIGINT/SIGTERM handling for graceful shutdown.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/signal-handlers

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.

@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 `@src/main.rs`:
- Line 87: The ctrl-c handler setup in main has a typo in the expect message,
making the panic text unclear if it ever triggers. Update the expect call on
ctrl_c in main to use a plain, correctly spelled message like “failed to install
sigint handler” so the error reads clearly when signal::ctrl_c() fails.
🪄 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: 17f4b5a3-2aa1-4719-9188-e2f511ac4eaa

📥 Commits

Reviewing files that changed from the base of the PR and between c3f6ef1 and f38d7c9.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • src/main.rs
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: build (cpu)
  • GitHub Check: Analyze (rust)
🔇 Additional comments (3)
Cargo.toml (1)

21-21: LGTM!

src/main.rs (2)

40-40: LGTM!


84-97: LGTM!

Comment thread src/main.rs Outdated
@apognu apognu force-pushed the feat/signal-handlers branch 5 times, most recently from d03fdfd to d744b05 Compare June 27, 2026 07:56
@apognu apognu force-pushed the feat/signal-handlers branch from d744b05 to 882bc71 Compare June 27, 2026 07:59

@Pascal-Delange Pascal-Delange 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.

Thx!

@apognu apognu merged commit 83f1079 into main Jun 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants