fix: Tor toggle tries systemd before container restart

The toggle handler only tried `podman restart archy-tor` which fails
on servers running Tor as a systemd service. Now tries
`systemctl restart tor` first (like the rotation handler already does),
falling back to container restart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-16 17:41:32 +00:00
parent 2e753c8d70
commit c02ce36f69

View File

@@ -330,15 +330,24 @@ impl RpcHandler {
info!(app = app_id, "Disabled Tor access — removed hidden service dir");
}
// Restart archy-tor to apply changes
let status = tokio::process::Command::new("sudo")
.args(["podman", "restart", "archy-tor"])
// Restart Tor to apply changes — try system service first, then container
let system_ok = tokio::process::Command::new("sudo")
.args(["systemctl", "restart", "tor"])
.status()
.await
.context("Failed to restart archy-tor")?;
.map(|s| s.success())
.unwrap_or(false);
if !status.success() {
warn!("archy-tor restart failed after toggle");
if !system_ok {
let container_ok = tokio::process::Command::new("sudo")
.args(["podman", "restart", "archy-tor"])
.status()
.await
.map(|s| s.success())
.unwrap_or(false);
if !container_ok {
warn!("Failed to restart Tor after toggle");
}
}
// If enabling, wait for hostname to appear