zeroclaw-labs/zeroclaw · critical · anyhow::Error
rc-service restart failed: {}
Error message
rc-service restart failed: {} What it means
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.
Source
Thrown at crates/zeroclaw-channels/src/orchestrator/mod.rs:8791
return Ok(true);
}
if cfg!(target_os = "linux") {
// OpenRC (system-wide) takes precedence over systemd (user-level)
let openrc_init_script = PathBuf::from("/etc/init.d/zeroclaw");
if openrc_init_script.exists()
&& let Ok(status_output) = Command::new("rc-service").args(OPENRC_STATUS_ARGS).output()
{
// rc-service exits 0 if running, non-zero otherwise
if status_output.status.success() {
let restart_output = Command::new("rc-service")
.args(OPENRC_RESTART_ARGS)
.output()
.context("Failed to restart OpenRC daemon service")?;
if !restart_output.status.success() {
let stderr = String::from_utf8_lossy(&restart_output.stderr);
anyhow::bail!("rc-service restart failed: {}", stderr.trim());
}
return Ok(true);
}
}
// Systemd (user-level)
let home = directories::UserDirs::new()
.map(|u| u.home_dir().to_path_buf())
.context("Could not find home directory")?;
let unit_path: PathBuf = home
.join(".config")
.join("systemd")
.join("user")
.join("zeroclaw.service");
if !unit_path.exists() {
return Ok(false);
}
View on GitHub (pinned to 88bb9c8533)
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
Example fix
# before: restart fails after binary moved # rc-service restart failed: /usr/bin/zeroclaw: No such file or directory # after sudo rc-update del zeroclaw default sudo cp contrib/openrc/zeroclaw /etc/init.d/ # or edit program path sudo rc-update add zeroclaw default sudo rc-service zeroclaw start
Defensive patterns
Strategy: fallback
Validate before calling
if !Path::new("/etc/init.d/zeroclaw").exists() {
return Ok(()); // no OpenRC service installed
}
let status = Command::new("rc-service").args(["zeroclaw", "status"]).output()?;
if !status.status.success() { return Ok(()); } // not running; skip restart path Try / catch
if let Err(e) = maybe_restart_managed_daemon_service() {
eprintln!("restart failed ({e:#}); recover with `sudo rc-service zeroclaw start`");
// alert: prior stop means the daemon may now be DOWN
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- systemctl restart failed: {}
- launchctl start failed: {}
- the OpenRC log writer is only supported on Linux
- Could not detect init system. Supported: systemd, OpenRC. Us
- No log files found at {}. Is the service installed?
AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23).
Data as JSON: /api/errors/90ae8a3c66d86941.
Report an issue: GitHub.