bug fixing and deploy and build diagnostics

This commit is contained in:
Dorian
2026-03-22 03:30:21 +00:00
parent 1f8287c4c3
commit e4e0ef4f11
198 changed files with 21703 additions and 19587 deletions

View File

@@ -5,7 +5,7 @@ use chrono::Timelike;
use serde::{Deserialize, Serialize};
use std::path::Path;
use tokio::fs;
use tracing::{debug, info, warn};
use tracing::{debug, info};
const DEFAULT_UPDATE_MANIFEST_URL: &str =
"https://raw.githubusercontent.com/archipelago-os/releases/main/manifest.json";
@@ -301,83 +301,6 @@ pub async fn apply_update(data_dir: &Path) -> Result<()> {
Ok(())
}
/// Rolling container restart — restarts containers one at a time with health checks.
/// This enables zero-downtime updates for containerized apps.
pub async fn rolling_container_restart() -> Result<RollingRestartReport> {
use std::process::Command;
let output = Command::new("podman")
.args(["ps", "--format", "{{.Names}}"])
.output()
.context("Failed to list containers")?;
let names: Vec<String> = String::from_utf8_lossy(&output.stdout)
.lines()
.map(|s| s.trim().to_string())
.filter(|s| !s.is_empty())
.collect();
let total = names.len();
let mut restarted = 0;
let mut failed = Vec::new();
info!(total = total, "Starting rolling container restart");
for name in &names {
debug!(container = %name, "Restarting container");
let restart = Command::new("podman")
.args(["restart", "--time", "30", name])
.output();
match restart {
Ok(out) if out.status.success() => {
// Wait for container to be healthy
let mut healthy = false;
for _ in 0..12 {
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
let check = Command::new("podman")
.args(["inspect", name, "--format", "{{.State.Status}}"])
.output();
if let Ok(out) = check {
let status = String::from_utf8_lossy(&out.stdout).trim().to_string();
if status == "running" {
healthy = true;
break;
}
}
}
if healthy {
restarted += 1;
debug!(container = %name, "Container restarted successfully");
} else {
failed.push(name.clone());
warn!(container = %name, "Container not healthy after restart");
}
}
_ => {
failed.push(name.clone());
warn!(container = %name, "Container restart command failed");
}
}
}
info!(restarted = restarted, failed = failed.len(), "Rolling restart complete");
Ok(RollingRestartReport {
total,
restarted,
failed,
})
}
/// Report from a rolling container restart.
#[derive(Debug, Serialize, Deserialize)]
pub struct RollingRestartReport {
pub total: usize,
pub restarted: usize,
pub failed: Vec<String>,
}
/// Rollback to the previous version from backup.
pub async fn rollback_update(data_dir: &Path) -> Result<()> {
let backup_dir = data_dir.join("update-backup");