Repository navigation
fix(huntsman): Add SIGTERM listener for storage server, scheduler server, and execution manager (fixes #393).
#416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: y-scope/spider
Length of output: 487
🏁 Script executed:
Repository: y-scope/spider
Length of output: 231
🌐 Web query:
Tokio signal Unix install signal handler when created documentation💡 Result:
In Tokio, signal handlers are installed lazily [1][2]. When you create a new tokio::signal::unix::Signal instance for a specific signal kind, the underlying OS signal handler is installed the first time that signal is registered for the process [3][1]. Key characteristics of this mechanism include: 1. Process-wide Scope: Once the signal handler is installed for a specific signal kind, it replaces the default platform behavior (SIG_DFL) for the duration of the entire process [3][1]. 2. Persistence: Dropping the Signal instance does not restore the original default signal handler [3][4]. Because signals are a global resource, Tokio's handler will continue to intercept that signal even after the listener is dropped [3][4]. If no active listeners are registered when a signal is subsequently received, the signal may be silently consumed by Tokio without the default system action (such as process termination) taking effect [4]. 3. Implementation Detail: Internally, Tokio uses a "self-pipe" pattern (typically using a UnixStream pair) to bridge the signal handler to the async reactor [5]. This allows the signal handler to remain minimal and safe while notifying the asynchronous runtime that a signal event has occurred [5][4]. Best practices for handling these behaviors include: - Keep Signal listeners active throughout the lifecycle of your application if you intend to catch those signals, or manage the signal state manually if you must drop them [4]. - For graceful shutdowns, you can use tokio::select! to monitor for signals alongside other application tasks [6][7]. - Be aware that if your application integrates with other libraries or languages (like Go) that also register signal handlers, conflicts may occur if the handlers are not configured compatibly [2]. For most use cases, creating a Signal instance via tokio::signal::unix::signal(SignalKind::...) is the standard approach to receiving asynchronous notifications for OS signals [8][9].
Citations:
🌐 Web query:
docs Tokio tokio::signal::unix::Signal installs Unix handler only when created manual💡 Result:
The statement that Tokio's Unix signal handler is only installed when created manually is correct in the sense that the registration process is triggered lazily upon the creation of a Signal listener [1][2]. Specifically, the behavior works as follows: 1. Lazy Installation: The underlying OS signal handler is not installed globally when the Tokio runtime starts. Instead, it is registered the first time a Signal instance (or a related helper like ctrl_c) is created for a specific SignalKind [1][3]. 2. Persistence: Once a signal handler has been registered for a particular signal kind, it remains installed for the duration of the entire process [1][4]. The underlying libc signal handler is never unregistered, even if the Signal instance that triggered the initial registration is dropped [1][5]. 3. Impact: By registering a handler, Tokio effectively takes over the handling of that signal, replacing the default platform behavior (e.g., terminating the process on SIGINT) with the capability to translate that signal into an asynchronous stream event [1][3]. Subsequent deliveries of that signal will continue to be captured by Tokio, and the process's default behavior will not be restored even if the original Signal listener is destroyed [1][3]. In summary, you must explicitly create a listener to "opt-in" to handling a specific Unix signal within your application, at which point the global handler for that signal becomes active for the remainder of the process's lifecycle [1][4].
Citations:
🏁 Script executed:
Repository: y-scope/spider
Length of output: 17460
Install all SIGTERM handlers before startup work begins.
Tokio only installs the Unix handler when
signal(...)/ctrl_c()is first registered, so before those calls SIGTERM keeps its default termination behaviour.components/spider-execution-manager/src/bin/execution_manager.rs#L68-L70: register before creating the runtime or spawningruntime.run().components/spider-scheduler/src/bin/grpc_server.rs#L63-L65: register before config/storage/runtime/listener setup.components/spider-storage/src/bin/grpc_server.rs#L58-L60: register before config/runtime/listener/server setup.📍 Affects 3 files
components/spider-execution-manager/src/bin/execution_manager.rs#L68-L70(this comment)components/spider-scheduler/src/bin/grpc_server.rs#L63-L65components/spider-storage/src/bin/grpc_server.rs#L58-L60🤖 Prompt for AI Agents