pub struct Supervisor { /* private fields */ }Expand description
Process supervisor for subc-owned singleton modules.
Implementations§
Source§impl Supervisor
impl Supervisor
pub fn new(registry: Arc<Registry>, restart_policy: RestartPolicy) -> Self
pub fn with_drain_timeout(self, drain_timeout: Duration) -> Self
pub fn with_process_liveness( self, process_liveness: Arc<SupervisorProcessLiveness>, ) -> Self
pub fn with_connection_file_path( self, connection_file_path: impl Into<PathBuf>, ) -> Self
Sourcepub fn with_capture_logs_dir(self, logs_dir: impl Into<PathBuf>) -> Self
pub fn with_capture_logs_dir(self, logs_dir: impl Into<PathBuf>) -> Self
Enables daemon-owned capture files for supervised stdout and stderr.
Sourcepub fn with_daemon_incarnation(self, daemon_incarnation: String) -> Self
pub fn with_daemon_incarnation(self, daemon_incarnation: String) -> Self
Names this daemon lifetime in spawn events, independently of whether a terminal journal is configured.
Sourcepub fn with_terminal_journal(
self,
path: PathBuf,
daemon_incarnation: String,
) -> Self
pub fn with_terminal_journal( self, path: PathBuf, daemon_incarnation: String, ) -> Self
Enables best-effort history shared by every supervised module. Without it, terminal history is kept only in each module’s in-memory ring.
pub fn with_forwarding(self, forwarding: Arc<ForwardingTable>) -> Self
pub fn with_handle(self, supervisor_handle: SupervisorHandle) -> Self
pub fn with_health_config(self, health: HealthConfig) -> Self
Sourcepub fn with_live_children_record(self, path: impl Into<PathBuf>) -> Self
pub fn with_live_children_record(self, path: impl Into<PathBuf>) -> Self
Keeps a record of every live child at path, rewritten on each spawn and
reap, for the orphan sweep a later daemon runs at boot. Without it no
record is kept.
pub fn with_cgroup_placement(self, cgroup_placement: Option<Placement>) -> Self
Sourcepub fn spawn(
&self,
spec: ModuleSpec,
) -> Result<SupervisedModule, SuperviseError>
pub fn spawn( &self, spec: ModuleSpec, ) -> Result<SupervisedModule, SuperviseError>
Spawn spec.program and start monitoring it.
The child is expected to parse --subc <connection-file-path>, read the
TCP+key connection file, authenticate to the already-running listener, and
register with channel-0 HELLO using spec.module_id as its manifest id.
Sourcepub fn supervise_configured(
&self,
spec: ModuleSpec,
enabled: bool,
) -> Result<SupervisedModule, SuperviseError>
pub fn supervise_configured( &self, spec: ModuleSpec, enabled: bool, ) -> Result<SupervisedModule, SuperviseError>
Start supervising a module declared in daemon configuration.
Unlike Self::spawn, this records disabled modules and immediate spawn
failures in the supervisor handle so operator-facing supervisor.list
reflects every configured module while daemon startup continues.
Sourcepub fn supervise_configured_with_health(
&self,
spec: ModuleSpec,
enabled: bool,
health: HealthConfig,
drain_timeout_ms: Option<u64>,
restart_policy: RestartPolicy,
) -> Result<SupervisedModule, SuperviseError>
pub fn supervise_configured_with_health( &self, spec: ModuleSpec, enabled: bool, health: HealthConfig, drain_timeout_ms: Option<u64>, restart_policy: RestartPolicy, ) -> Result<SupervisedModule, SuperviseError>
Supervise a configured module with its own health, drain, and crash
budget. The restart policy is per-module because the config file is:
modules.<id>.restart resolves to a full policy at parse time, and a
module that is expensive to restart should not be forced onto the same
budget as one that is cheap.