diff --git a/crates/horizon-server/src/update.rs b/crates/horizon-server/src/update.rs index 81bbaad3f..bebbedc76 100644 --- a/crates/horizon-server/src/update.rs +++ b/crates/horizon-server/src/update.rs @@ -505,15 +505,30 @@ fn switch_to(dir: &Path, install: &Install, tag: &str, timeout: Duration) -> Res std::thread::sleep(Duration::from_millis(500)); let status = client.call("GET", "/api/v1/status", None)?; if finished(&status) > before { - println!(); let update = &status["update"]; let last = update["last"].as_str().unwrap_or_default().to_owned(); - return if update["ok"] == true { - println!("{last}"); - Ok(()) + if update["ok"] == true { + println!("\n{last}"); + return Ok(()); + } + // Rolled back (or stayed): say so once the game is up again on the release it went back to. + let mut phase = status["phase"].as_str().unwrap_or_default().to_owned(); + let until = Instant::now() + crate::api::UPDATE_TIMEOUT; + while phase != "running" && phase != "stopping" && Instant::now() < until { + std::thread::sleep(Duration::from_millis(500)); + print!("."); + let _ = std::io::Write::flush(&mut std::io::stdout()); + phase = client.call("GET", "/api/v1/status", None)?["phase"] + .as_str() + .unwrap_or_default() + .to_owned(); + } + println!(); + return Err(if phase == "running" { + format!("{last}. The game is up again.") } else { - Err(last) - }; + last + }); } if Instant::now() > deadline { println!(); diff --git a/docs/hosting.md b/docs/hosting.md index 346eb7c8b..7e104d15e 100644 --- a/docs/hosting.md +++ b/docs/hosting.md @@ -204,6 +204,8 @@ horizon-server restore BACKUP [--yes] horizon-server service install|uninstall|print [--system] horizon-server panel a one-time login link for the web panel horizon-server import FILE server.toml from a vanilla server.properties +horizon-server update [--check] install the newest release and restart on it (below) +horizon-server rollback back to the release before ``` While the server runs, `op`, `whitelist` and `cmd` go to the game's console, so they act exactly as vanilla's @@ -213,14 +215,31 @@ console commands do. While it's stopped, they edit vanilla's files directly. Any The server restarts the game by itself if it crashes: after 5 s, then waiting longer each time, up to 5 minutes. It keeps the crash report and gives up after 5 crashes in 10 minutes, and `status` says why. -Coming: `update` and `rollback`, `console` (attach to a server running in the background), `ban` and -`pardon` as their own commands, and `mcp` (an MCP server so an AI assistant can run the server). +**Updates** (a server installed with the install script). The server checks for a newer release a minute +after it starts and every 6 hours after, and says so in its log, in `status` and in the panel; it never +updates by itself. `horizon-server update --check` asks once. `horizon-server update`: + +1. downloads the newest release and checks it against the SHA-256 GitHub publishes for it; +2. stops the game, backs up the world (`backups/