Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat: remove gateway install from restarting gateway step
Vanalitef597dab1ec18
diff --git a/src-tauri/src/core/openclaw/commands.rs b/src-tauri/src/core/openclaw/commands.rsindex bc2f87180..ecc71d566 100644--- a/src-tauri/src/core/openclaw/commands.rs+++ b/src-tauri/src/core/openclaw/commands.rs@@ -679,8 +679,7 @@ async fn run_doctor_fix() -> Result<(), String> {}}-/// Restart the gateway. Docker: `docker restart`. Direct process: stop → install → start-/// (launchd caches service args, so a plain `gateway restart` won't pick up config changes).+/// Restart the gateway. Docker: `docker restart`. Direct process: stop → spawn child.async fn restart_gateway_cli() -> Result<(), String> {if is_docker_container_running().await {let mut cmd = Command::new("docker");@@ -707,20 +706,12 @@ async fn restart_gateway_cli() -> Result<(), String> {tokio::time::sleep(std::time::Duration::from_secs(1)).await;- // Re-register service with --runtime bun when bundled Bun is available.- // On Windows this requires admin (schtasks) and may fail.- let install_args: Vec<&str> = vec!["gateway", "install"];- let install_output = openclaw_command(&install_args).await- .stdout(Stdio::piped())- .stderr(Stdio::piped())- .output()- .await;- let service_installed = install_output- .as_ref()- .map(|o| o.status.success())- .unwrap_or(false);+ // Check if a system service is already registered (launchd plist on Mac,+ // systemd unit on Linux) — if so, use `gateway start` to let the service+ // manager handle it. Otherwise spawn as a direct child process.+ let service_exists = is_gateway_service_registered();- if service_installed {+ if service_exists {let output = openclaw_command(&["gateway", "start"]).await.stdout(Stdio::piped()).stderr(Stdio::piped())@@ -730,14 +721,19 @@ async fn restart_gateway_cli() -> Result<(), String> {if !output.status.success() {let stderr = String::from_utf8_lossy(&output.stderr);- log::warn!("Gateway start failed: {}", stderr);+ log::warn!("Gateway start via service failed: {}, falling back to child process", stderr);+ let mut cmd = openclaw_command(&["gateway"]).await;+ cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());+ hide_window(&mut cmd);+ if let Err(e) = cmd.spawn() {+ log::warn!("Failed to spawn openclaw gateway: {}", e);+ }}} else {- // Service registration failed (e.g. Windows without admin).- // Spawn `openclaw gateway` as a foreground child process.- log::info!("Service install unavailable, restarting gateway as child process");+ log::info!("No gateway service registered, restarting as child process");let mut cmd = openclaw_command(&["gateway"]).await;- cmd.stdout(Stdio::piped()).stderr(Stdio::piped());+ cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null());+ hide_window(&mut cmd);if let Err(e) = cmd.spawn() {log::warn!("Failed to spawn openclaw gateway: {}", e);}@@ -745,6 +741,24 @@ async fn restart_gateway_cli() -> Result<(), String> {Ok(())}+/// Check if a gateway system service is already registered (without running `gateway install`).+fn is_gateway_service_registered() -> bool {+ #[cfg(target_os = "macos")]+ {+ if let Some(home) = dirs::home_dir() {+ return home.join("Library/LaunchAgents/ai.openclaw.gateway.plist").exists();+ }+ }+ #[cfg(target_os = "linux")]+ {+ if let Some(home) = dirs::home_dir() {+ return home.join(".config/systemd/user/openclaw-gateway.service").exists();+ }+ }+ // Windows uses Task Scheduler — no simple file check, default to child process.+ false+}+/// Clear stale files that may cause setup failures.async fn clear_stale_openclaw_data() -> Result<(), String> {let config_dir = get_openclaw_config_dir()?;