Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

feat(node): add OS signal handling for graceful shutdown#3146

Merged
theochap merged 4 commits intoop-rs:mainfrom
Himess:graceful-shutdown-3091
Jan 8, 2026
Merged

feat(node): add OS signal handling for graceful shutdown#3146
theochap merged 4 commits intoop-rs:mainfrom
Himess:graceful-shutdown-3091

Conversation

@Himess
Copy link
Contributor

@Himess Himess commented Dec 5, 2025

Summary

  • Added shutdown_signal() function to listen for SIGTERM and SIGINT
  • Spawned a task in RollupNode::start() that triggers the existing CancellationToken when OS signals are received
  • All actors already support graceful shutdown via CancellationToken, this just adds the missing OS signal handling

Changes

  • Modified crates/node/service/src/service/node.rs
  • Cross-platform support: SIGTERM on Unix, Ctrl+C (SIGINT) on all platforms

Closes #3091

Implements graceful shutdown for kona node by adding OS signal
handlers (SIGTERM, SIGINT) that trigger the existing CancellationToken.

All actors already receive CancellationToken for graceful shutdown,
this change adds the missing OS signal handling to trigger it.

Fixes op-rs#3091
@Himess Himess force-pushed the graceful-shutdown-3091 branch from 3021e05 to 0b2dde2 Compare December 5, 2025 11:04
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.9%. Comparing base (820ff00) to head (eca7448).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/node/service/src/service/util.rs 87.5% 2 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@theochap theochap left a comment

Choose a reason for hiding this comment

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

Looks good, instead of using a separate thread, let's move the handler to the place where we instantiate the actors (in the macro's select statement).

I would like to see some additional simplifications to the cancellation logic before we close the linked issue. In particular, we should handle actor cancellation at the rollup_node::start level

- Move shutdown_signal() from node.rs to util.rs
- Integrate signal handling directly into spawn_and_wait! macro's select loop
- Remove separate tokio::spawn task for signal handling
- Signal handling now occurs at the same level as actor lifecycle management

This addresses the review feedback to handle signals in the macro's select
statement rather than using a separate thread.
@Himess
Copy link
Contributor Author

Himess commented Dec 12, 2025

Looks good, instead of using a separate thread, let's move the handler to the place where we instantiate the actors (in the macro's select statement).

I would like to see some additional simplifications to the cancellation logic before we close the linked issue. In particular, we should handle actor cancellation at the rollup_node::start level

Done! Moved the signal handling into the macro's select loop as you suggested.
The shutdown_signal function is now in util.rs and gets called directly from spawn_and_wait instead of spawning a separate task.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 3, 2026

This pull request has been automatically marked as stale because it has been inactive for 3 weeks.
It will be closed in 1 week if no further activity occurs.
If you believe this PR should remain open, please add the M-prevent-stale label or leave a comment.

@github-actions github-actions bot added M-stale and removed M-stale labels Jan 3, 2026
@theochap theochap added this pull request to the merge queue Jan 8, 2026
Merged via the queue into op-rs:main with commit d822621 Jan 8, 2026
47 checks passed
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 15, 2026
…3146)

## Summary
- Added `shutdown_signal()` function to listen for SIGTERM and SIGINT
- Spawned a task in `RollupNode::start()` that triggers the existing
`CancellationToken` when OS signals are received
- All actors already support graceful shutdown via CancellationToken,
this just adds the missing OS signal handling

## Changes
- Modified `crates/node/service/src/service/node.rs`
- Cross-platform support: SIGTERM on Unix, Ctrl+C (SIGINT) on all
platforms

Closes #3091
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(node): Handle termination gracefully

2 participants