{"record":{"id":"90ae8a3c66d86941","repo":"zeroclaw-labs/zeroclaw","slug":"rc-service-restart-failed","errorCode":null,"errorMessage":"rc-service restart failed: {}","messagePattern":"rc-service restart failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"crates/zeroclaw-channels/src/orchestrator/mod.rs","lineNumber":8791,"sourceCode":"\n        return Ok(true);\n    }\n\n    if cfg!(target_os = \"linux\") {\n        // OpenRC (system-wide) takes precedence over systemd (user-level)\n        let openrc_init_script = PathBuf::from(\"/etc/init.d/zeroclaw\");\n        if openrc_init_script.exists()\n            && let Ok(status_output) = Command::new(\"rc-service\").args(OPENRC_STATUS_ARGS).output()\n        {\n            // rc-service exits 0 if running, non-zero otherwise\n            if status_output.status.success() {\n                let restart_output = Command::new(\"rc-service\")\n                    .args(OPENRC_RESTART_ARGS)\n                    .output()\n                    .context(\"Failed to restart OpenRC daemon service\")?;\n                if !restart_output.status.success() {\n                    let stderr = String::from_utf8_lossy(&restart_output.stderr);\n                    anyhow::bail!(\"rc-service restart failed: {}\", stderr.trim());\n                }\n                return Ok(true);\n            }\n        }\n\n        // Systemd (user-level)\n        let home = directories::UserDirs::new()\n            .map(|u| u.home_dir().to_path_buf())\n            .context(\"Could not find home directory\")?;\n        let unit_path: PathBuf = home\n            .join(\".config\")\n            .join(\"systemd\")\n            .join(\"user\")\n            .join(\"zeroclaw.service\");\n        if !unit_path.exists() {\n            return Ok(false);\n        }\n","sourceCodeStart":8773,"sourceCodeEnd":8809,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-channels/src/orchestrator/mod.rs#L8773-L8809","documentation":"Thrown by maybe_restart_managed_daemon_service on Linux when an OpenRC service is detected (/etc/init.d/zeroclaw exists and `rc-service zeroclaw status` reports running) but `rc-service zeroclaw restart` exits non-zero. The prior status check succeeded, so a failed restart likely leaves the service stopped or in a degraded state; the surrounding caller surfaces a manual restart command.","triggerScenarios":"A config-mutating operation (e.g. allowlist save) triggers auto-reload on an Alpine/Gentoo-style OpenRC host where /etc/init.d/zeroclaw exists and the service is up, and `rc-service zeroclaw restart` fails — typically the init script's stop/start commands erroring (bad binary path, config crash on start, or insufficient root privileges for the invoking user).","commonSituations":"Running the CLI as a non-root user on a system-wide OpenRC service; init script references a deleted/moved zeroclaw binary; daemon config became invalid so the start half of restart fails; OpenRC supervise-daemon timeout during slow shutdown.","solutions":["Check service state: `rc-service zeroclaw status`; if stopped, start it manually with `sudo rc-service zeroclaw start` and read the error output","Inspect /etc/init.d/zeroclaw and confirm its command/program path matches the installed binary; reinstall the init script if stale","Run the zeroclaw binary in the foreground with the same config to find why startup fails, and fix the config error","If privileges were the issue, run config-reload operations as a user permitted to control the service, or switch to the user-level systemd path"],"exampleFix":"# before: restart fails after binary moved\n# rc-service restart failed: /usr/bin/zeroclaw: No such file or directory\n\n# after\nsudo rc-update del zeroclaw default\nsudo cp contrib/openrc/zeroclaw /etc/init.d/   # or edit program path\nsudo rc-update add zeroclaw default\nsudo rc-service zeroclaw start","handlingStrategy":"fallback","validationCode":"if !Path::new(\"/etc/init.d/zeroclaw\").exists() {\n    return Ok(()); // no OpenRC service installed\n}\nlet status = Command::new(\"rc-service\").args([\"zeroclaw\", \"status\"]).output()?;\nif !status.status.success() { return Ok(()); } // not running; skip restart path","typeGuard":null,"tryCatchPattern":"if let Err(e) = maybe_restart_managed_daemon_service() {\n    eprintln!(\"restart failed ({e:#}); recover with `sudo rc-service zeroclaw start`\");\n    // alert: prior stop means the daemon may now be DOWN\n}","preventionTips":["Run config-mutating CLI commands as a user permitted to control the system service","Reinstall the init script whenever the binary path changes","Validate config in the foreground before any operation that restarts the service"],"tags":["daemon","openrc","linux","service-restart","zeroclaw"],"backgroundTag":"service-start-failure","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}