huskies: merge 1147 story One-active-gateway invariant via pidfile+flock — prevent double-gateway during restarts

This commit is contained in:
dave
2026-05-19 18:34:41 +00:00
parent 918f18c200
commit be7bdf8304
4 changed files with 136 additions and 1 deletions
+4 -1
View File
@@ -163,7 +163,10 @@ pub async fn execute_trampoline_core(job: &TrampolineJob) -> Result<(), String>
}
let _ = std::fs::copy(&job.old_binary_path, &job.backup_binary_path);
// Kill old gateway.
// Kill old gateway. Killing the process closes its file descriptors,
// which releases the exclusive flock held on `$HOME/.huskies/gateway.pid`.
// The new gateway (spawned below) will then acquire that flock on startup,
// ensuring the one-active-gateway invariant is maintained across the swap.
kill_gateway_process(job.gateway_pid)?;
// Start new gateway.