pub struct Spawner { /* private fields */ }Expand description
Agent-agnostic process spawner with tracking and log capture.
Manages the full lifecycle: claim → spawn → track → complete/release.
Implementations§
Source§impl Spawner
impl Spawner
Sourcepub fn spawn(
&mut self,
unit_id: &str,
unit_title: &str,
action: AgentAction,
config: &Config,
mana_dir: Option<&Path>,
) -> Result<()>
pub fn spawn( &mut self, unit_id: &str, unit_title: &str, action: AgentAction, config: &Config, mana_dir: Option<&Path>, ) -> Result<()>
Spawn an agent for a unit.
- Selects the command template from config (
runorplan) - Substitutes
{id}with the unit ID - Claims the unit via
mana claim - Opens a log file for stdout/stderr capture
- Spawns the process via
sh -c <cmd> - Registers the process in the agents persistence file
Sourcepub fn check_completed(&mut self) -> Vec<CompletedAgent>
pub fn check_completed(&mut self) -> Vec<CompletedAgent>
Non-blocking check for completed agents.
Calls try_wait() on each running process. Completed agents are
removed from the running map and returned. On failure, the unit
claim is released.
Sourcepub fn running_count(&self) -> usize
pub fn running_count(&self) -> usize
Number of currently running agents.
Sourcepub fn can_spawn(&self, max_concurrent: u32) -> bool
pub fn can_spawn(&self, max_concurrent: u32) -> bool
Whether a new agent can be spawned given the concurrency limit.
Sourcepub fn list_running(&self) -> Vec<&AgentProcess>
pub fn list_running(&self) -> Vec<&AgentProcess>
Immutable view of all running agent processes.
Sourcepub fn shutdown_all(&mut self, grace_period: Duration)
pub fn shutdown_all(&mut self, grace_period: Duration)
Gracefully shutdown all running agent processes.
Sends SIGTERM first, waits up to grace_period for processes to exit,
then falls back to SIGKILL for any remaining. Releases claims on all
affected units.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Spawner
impl RefUnwindSafe for Spawner
impl Send for Spawner
impl Sync for Spawner
impl Unpin for Spawner
impl UnsafeUnpin for Spawner
impl UnwindSafe for Spawner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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