diff --git a/CHANGELOG.md b/CHANGELOG.md index d163dcff..570eb764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,12 @@ and listed with their assets on the ### Fixed +- **A restart no longer ends the stack's daemon.** Since the daemon ends + with the last tree (0.41.0), a restart (`restart_on`, `devstack restart`, + a rebuild) could end it: between the service's stop and its start + nothing ran, and on Windows the stop takes seconds. The daemon ended in + that gap, and the dashboard and the CLI found no daemon until the next + `up`. A restart under way now counts as running. - **Python creating `__pycache__` no longer restarts a dev server** (#463). On Windows the OS reports a folder as modified when an entry appears in it, beside the entry's own event; with a folder in `restart_on` diff --git a/crates/devstack-daemon/src/supervisor/candidate.rs b/crates/devstack-daemon/src/supervisor/candidate.rs index 3388ed40..b63b2d4e 100644 --- a/crates/devstack-daemon/src/supervisor/candidate.rs +++ b/crates/devstack-daemon/src/supervisor/candidate.rs @@ -595,6 +595,22 @@ mod tests { panic!("late past the deadline at every try: {tries:?}"); } + /// A restart under way keeps the daemon: between its stop and its start + /// nothing of the service runs, and the daemon must not end there. + #[test] + fn a_restart_under_way_counts_as_running() { + let (_d, _rt, sup) = two_after_a_job(); + assert!(!sup.runs_anything(), "nothing started"); + *sup.restarts_under_way + .lock() + .unwrap() + .entry("a".into()) + .or_default() += 1; + assert!(sup.runs_anything(), "a restart between its stop and start"); + *sup.restarts_under_way.lock().unwrap().get_mut("a").unwrap() -= 1; + assert!(!sup.runs_anything()); + } + /// A change reported after a restart began waits for the restart, past /// its quiet period: the restart may have built it already (#233). #[test] diff --git a/crates/devstack-daemon/src/supervisor/lifecycle.rs b/crates/devstack-daemon/src/supervisor/lifecycle.rs index ab9b5711..f1407445 100644 --- a/crates/devstack-daemon/src/supervisor/lifecycle.rs +++ b/crates/devstack-daemon/src/supervisor/lifecycle.rs @@ -142,6 +142,16 @@ impl Supervisor { pub fn runs_anything(&self) -> bool { use crate::state::Status; self.upping.load(Ordering::SeqCst) > 0 + // A restart stops before it starts: between the two nothing of + // the service runs, and on Windows the stop takes seconds. The + // daemon ended there, and the start that followed ran in a + // daemon on its way out. + || self + .restarts_under_way + .lock() + .unwrap() + .values() + .any(|n| *n > 0) || self .slots .lock()