Start ClawShell directly by spawning a child process (no service manager).
(
toml_config_path: &std::path::Path,
)
| 2134 | |
| 2135 | /// Start ClawShell directly by spawning a child process (no service manager). |
| 2136 | fn start_clawshell_direct( |
| 2137 | toml_config_path: &std::path::Path, |
| 2138 | ) -> Result<(), Box<dyn std::error::Error>> { |
| 2139 | let exe = std::env::current_exe()?; |
| 2140 | let log_path = process::log_file_path(); |
| 2141 | let log_file = std::fs::OpenOptions::new() |
| 2142 | .create(true) |
| 2143 | .append(true) |
| 2144 | .open(&log_path)?; |
| 2145 | let log_stderr = log_file.try_clone()?; |
| 2146 | |
| 2147 | let child = std::process::Command::new(exe) |
| 2148 | .args([ |
| 2149 | "start", |
| 2150 | "--config", |
| 2151 | &toml_config_path.to_string_lossy(), |
| 2152 | "--foreground", |
| 2153 | ]) |
| 2154 | .stdout(log_file) |
| 2155 | .stderr(log_stderr) |
| 2156 | .stdin(std::process::Stdio::null()) |
| 2157 | .spawn()?; |
| 2158 | |
| 2159 | let pid = child.id(); |
| 2160 | tui::print_info("Process ID", &pid.to_string()); |
| 2161 | Ok(()) |
| 2162 | } |
no test coverage detected