pub struct NodeSupervisorHandle { /* private fields */ }Expand description
Running node supervisor.
Owns the supervised hogd-dev child and the JSON-RPC server. The handle
does no proactive supervision in the background: callers are responsible
for awaiting NodeSupervisorHandle::stopped (the supervisor-level
“run until something ends” entry point) or driving NodeSupervisorHandle::stop
directly. Both consume the handle so a single instance cannot be torn
down twice.
Implementations§
Source§impl NodeSupervisorHandle
impl NodeSupervisorHandle
Sourcepub async fn start(
config: NodeSupervisorConfig,
) -> Result<Self, NodeSupervisorError>
pub async fn start( config: NodeSupervisorConfig, ) -> Result<Self, NodeSupervisorError>
Spawn hogd-dev, wait for readiness, connect the scheduler x23 client, and start the JSON-RPC server.
On any failure after hogd-dev has started, the child is stopped before
the error is returned, so a failed start does not leave a hogd-dev
process behind.
Sourcepub async fn start_with_inherited_file(
config: NodeSupervisorConfig,
inherited_file: Option<File>,
) -> Result<Self, NodeSupervisorError>
pub async fn start_with_inherited_file( config: NodeSupervisorConfig, inherited_file: Option<File>, ) -> Result<Self, NodeSupervisorError>
Start a node with one inherited file descriptor, such as a locked bundle lease. The child and its descendants retain the open file description independently of this handle and process, including after SIGKILL. The executable must preserve inherited descriptors for this guarantee.
Sourcepub fn rpc_addr(&self) -> SocketAddr
pub fn rpc_addr(&self) -> SocketAddr
Bound JSON-RPC listen address. Differs from the configured address when
the caller asked for port 0.
Sourcepub fn hogd_readiness(&self) -> &HogdDevReadiness
pub fn hogd_readiness(&self) -> &HogdDevReadiness
Parsed hogd-dev readiness payload.
Sourcepub fn backend_planes(&self) -> BackendPlanes
pub fn backend_planes(&self) -> BackendPlanes
Backend plane status for startup reporting.
Sourcepub fn hogd_child_id(&self) -> Option<u32>
pub fn hogd_child_id(&self) -> Option<u32>
Operating-system process id for hogd-dev, if available.
Sourcepub fn manual_block_producer(&self) -> Option<ManualBlockProducer>
pub fn manual_block_producer(&self) -> Option<ManualBlockProducer>
In-process block production control when the supervisor runs in manual mode.
Sourcepub async fn stopped(self) -> Result<SupervisorStop, NodeSupervisorError>
pub async fn stopped(self) -> Result<SupervisorStop, NodeSupervisorError>
Wait until either hogd-dev exits or the JSON-RPC server stops, then tear the other side down.
If hogd-dev dies after readiness, the public JSON-RPC facade keeps
answering but every backend call would fail; this method observes
that and shuts the facade down so the CLI sees a clean stop instead
of silent malfunction. If the JSON-RPC server stops first (e.g. via
an external NodeSupervisorHandle::stop call), hogd-dev is shut
down with the configured grace timeout.
Returns a SupervisorStop describing which side ended first.
Sourcepub async fn run_until<F>(
self,
stop_signal: F,
) -> Result<SupervisorStop, NodeSupervisorError>
pub async fn run_until<F>( self, stop_signal: F, ) -> Result<SupervisorStop, NodeSupervisorError>
Wait until hogd-dev exits, the JSON-RPC server stops, or an external stop signal completes, then tear the remaining side down.
This is the CLI-friendly variant of NodeSupervisorHandle::stopped:
callers pass a future for Ctrl-C or another stop request without
losing the ability to shut hogd-dev down cleanly.
Sourcepub async fn stop(self) -> Result<ExitStatus, NodeSupervisorError>
pub async fn stop(self) -> Result<ExitStatus, NodeSupervisorError>
Stop the JSON-RPC server and shut hogd-dev down with the configured grace timeout. Consumes the handle.