From a7dd82a92f4a7b42bc50ac0a8a24b6987163cf1f Mon Sep 17 00:00:00 2001 From: barath-dev Date: Mon, 23 Nov 2026 14:18:42 +0530 Subject: [PATCH] Log why the server stopped before removing its marker The server removed ui.pid, then wrote "paddock stopped (...)" to its log. Whatever waits for ui.pid to go could read the log in between: the idle test did on Ubuntu CI (server_stops_itself_when_no_page_is_open, after the merge of #5), and found no "no page open" yet. The line is now written first, so once the marker is gone the log already says why. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013DS9XhJVN73JGnZEqrX89o --- src/server.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/server.rs b/src/server.rs index a2573c0..2a7d5dc 100644 --- a/src/server.rs +++ b/src/server.rs @@ -861,17 +861,23 @@ pub fn serve() -> Result<()> { for worker in workers { let _ = worker.join(); } + let restart = app.restart.load(Ordering::SeqCst); + // Said in the log before the marker goes: whatever waits for the marker to go + // (paddock stop, the tests) then finds the log already says why. + if restart { + eprintln!("{} paddock {VERSION} stopped; starting the new version", log_stamp()); + } else { + eprintln!("{} paddock stopped ({reason})", log_stamp()); + } // The pid file is the tool's own marker that a server is running. if fs::read_to_string(pid_file()).is_ok_and(|pid| pid.trim() == std::process::id().to_string()) { let _ = fs::remove_file(pid_file()); } - if app.restart.load(Ordering::SeqCst) { + if restart { // The listener is gone; the new program takes the port over. drop(server); - eprintln!("{} paddock {VERSION} stopped; starting the new version", log_stamp()); return start_detached(&os::installed_program()); } - eprintln!("{} paddock stopped ({reason})", log_stamp()); Ok(()) }