1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Process service for managing child processes
//!
//! This service provides process lifecycle management for CLI commands,
//! particularly for the `dev` and `run` commands that need to manage
//! multiple node processes.
//!
//! This is a thin wrapper around mecha10-runtime's ProcessManager,
//! delegating core process management to the runtime layer.
//!
//! The implementation is split across a few focused submodules, all of
//! which add `impl ProcessService` blocks for the struct defined here:
//!
//! - [`resolve`]: binary path resolution (framework dev mode, global installs, node-runner)
//! - [`spawn`]: plain process spawning primitives (inherited/piped output, env, working dir)
//! - [`spawn_node`]: node-oriented spawning (node-runner, standalone/direct)
//! - [`control`]: status, stop/restart, and cleanup of tracked processes
//! - [`build`]: cargo build helpers used before spawning nodes
use ProcessManager;
/// Process service for managing child processes
///
/// This is a thin wrapper around the runtime's ProcessManager,
/// adding CLI-specific conveniences and delegating core functionality
/// to the runtime layer.
///
/// # Examples
///
/// ```rust,ignore
/// use mecha10_cli::services::ProcessService;
///
/// # async fn example() -> anyhow::Result<()> {
/// let mut service = ProcessService::new();
///
/// // Spawn a node process
/// service.spawn_node("camera_driver", "target/debug/camera_driver", &[])?;
///
/// // Check status
/// let status = service.get_status();
/// println!("Running processes: {:?}", status);
///
/// // Stop a specific process
/// service.stop("camera_driver")?;
///
/// // Cleanup all processes
/// service.cleanup();
/// # Ok(())
/// # }
/// ```