Skip to main content

ProcessService

Struct ProcessService 

Source
pub struct ProcessService { /* private fields */ }

Implementations§

Source§

impl ProcessService

Source

pub fn build_node(&self, node_name: &str, release: bool) -> Result<()>

Build a specific node package. release controls whether to build in release mode.

Source

pub fn build_all(&self, release: bool) -> Result<()>

Build all nodes in the workspace. release controls whether to build in release mode.

Source§

impl ProcessService

Source

pub fn get_status(&mut self) -> HashMap<String, String>

Get status of all processes

Returns a HashMap mapping process names to status strings

Source

pub fn stop(&mut self, name: &str) -> Result<()>

Stop a specific process by name. Returns an error if the process is not found. Uses a default 10-second timeout for graceful shutdown; use stop_with_timeout for a custom one.

Source

pub fn stop_with_timeout(&mut self, name: &str, timeout: Duration) -> Result<()>

Stop a process with timeout for graceful shutdown. Tries graceful shutdown (SIGTERM on Unix), then force kills after the timeout.

Source

pub fn force_kill(&mut self, name: &str) -> Result<()>

Source

pub fn cleanup(&mut self)

Stop all processes gracefully in dependency order, delegating to the runtime’s ProcessManager.

Source

pub fn is_running(&mut self, name: &str) -> bool

Source

pub fn restart( &mut self, name: &str, binary_path: &str, args: &[&str], ) -> Result<u32>

Restart a specific process: stops it if running and starts it again.

Source

pub fn restart_all( &mut self, nodes: Vec<(&str, &str, Vec<&str>)>, ) -> Result<HashMap<String, u32>>

Restart all processes. nodes is a list of (name, binary_path, args) tuples.

Source§

impl ProcessService

Source

pub fn find_global_binary(node_name: &str) -> Option<PathBuf>

Find globally installed binary for a node. Searches ~/.cargo/bin/{node_name} then ~/.mecha10/bin/{node_name}.

Source

pub fn resolve_node_runner_path() -> String

Resolve path to mecha10-node-runner binary: global installation at ~/.cargo/bin/mecha10-node-runner, else falls back to relying on PATH.

Source

pub fn is_node_runner_available() -> bool

Check if mecha10-node-runner is available

Source§

impl ProcessService

Source

pub fn spawn_node( &mut self, name: &str, binary_path: &str, args: &[&str], ) -> Result<u32>

Spawn a node process, tracked under name. Returns an error if the process cannot be spawned.

Source

pub fn spawn_with_output( &mut self, name: &str, binary_path: &str, args: &[&str], ) -> Result<u32>

Spawn a process with output capture, tracked under name.

Source

pub fn spawn_with_env( &mut self, name: &str, binary_path: &str, args: &[&str], env: HashMap<String, String>, ) -> Result<u32>

Spawn a process with custom environment variables, tracked under name.

Source

pub fn spawn_in_dir( &mut self, name: &str, binary_path: &str, args: &[&str], working_dir: impl AsRef<Path>, ) -> Result<u32>

Spawn a process in a specific working directory, tracked under name.

Source

pub fn spawn_nodes( &mut self, nodes: Vec<(&str, &str, Vec<&str>)>, ) -> Result<HashMap<String, u32>>

Spawn multiple node processes from a list of (name, binary_path, args) tuples, returning a HashMap of node names to PIDs.

Source§

impl ProcessService

Source

pub fn spawn_node_runner( &mut self, node_identifier: &str, project_name: &str, project_env: Option<HashMap<String, String>>, ) -> Result<u32>

Spawn a node using mecha10-node-runner, which handles binary resolution, model pulling, and env setup. Returns the process ID of the spawned node-runner instance, or an error if it cannot be spawned.

Source

pub fn spawn_node_direct( &mut self, node_identifier: &str, _project_name: &str, project_env: Option<HashMap<String, String>>, ) -> Result<u32>

Spawn a node directly (standalone mode)

This is used when mecha10-node-runner is not available. Handles both framework nodes (via BinaryManager) and local project nodes (built and run directly).

Source§

impl ProcessService

Source

pub fn new() -> Self

Create a new process service

Source

pub fn track_dependency(&mut self, node: &str, dependencies: Vec<String>)

Track dependency relationship for a node. dependencies is the list of nodes node depends on.

Source

pub fn get_shutdown_order(&self) -> Vec<String>

Get shutdown order (reverse dependency order): nodes with dependents first, then their dependencies, so we never stop a node while others still depend on it.

Source

pub fn count(&self) -> usize

Get the number of tracked processes

Source

pub fn is_empty(&self) -> bool

Check if any processes are being tracked

Source

pub fn manager(&mut self) -> &mut ProcessManager

Get access to the underlying ProcessManager, for advanced operations.

Trait Implementations§

Source§

impl Default for ProcessService

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for ProcessService

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more