From 6aea9011f9d6555f8aeef754f2a6bdfe3498897d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Tue, 6 Oct 2026 10:12:13 +0500 Subject: [PATCH] Allow first SQUID startup to complete large database imports --- .../20261006-squid-first-start-timeout.md | 7 ++++++ crates/coa-core/src/driver.rs | 25 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20261006-squid-first-start-timeout.md diff --git a/changelog.d/20261006-squid-first-start-timeout.md b/changelog.d/20261006-squid-first-start-timeout.md new file mode 100644 index 0000000..f313b6e --- /dev/null +++ b/changelog.d/20261006-squid-first-start-timeout.md @@ -0,0 +1,7 @@ +--- +area: manager +type: fixed +audience: admins +title: Large SQUID database imports have more time to finish on first startup +--- +The Manager allows additional startup time when SQUID Playerbots is enabled, so its initial database import is not interrupted by the normal startup deadline. diff --git a/crates/coa-core/src/driver.rs b/crates/coa-core/src/driver.rs index 3ba7067..4979621 100644 --- a/crates/coa-core/src/driver.rs +++ b/crates/coa-core/src/driver.rs @@ -31,8 +31,9 @@ impl Verb { } } - fn timeout(self) -> Duration { + fn timeout(self, root: &Path) -> Duration { match self { + Verb::StartAll | Verb::StartWorld if squid_enabled(root) => Duration::from_secs(1800), Verb::StartAll | Verb::StartWorld => Duration::from_secs(420), Verb::StartMysql => Duration::from_secs(120), Verb::StopAll => Duration::from_secs(240), @@ -40,6 +41,14 @@ impl Verb { } } +fn squid_enabled(root: &Path) -> bool { + let active = root.join("Core/configs/modules/playerbots.conf"); + let path = if active.exists() { active } else { root.join("Core/configs/modules/playerbots.conf.dist") }; + std::fs::read(path).ok().and_then(|bytes| crate::config::parser::ConfFile::parse_bytes(&bytes).ok()) + .is_some_and(|config| config.get("AiPlayerbot.Enabled").is_none_or(|value| + !matches!(value.trim().trim_matches('"').to_ascii_lowercase().as_str(), "0" | "false" | "no" | "off"))) +} + #[derive(Debug, Clone, Serialize)] pub struct DriverOutcome { pub ok: bool, @@ -149,7 +158,7 @@ fn run_inner(root: &Path, verb: Verb, validating_update: bool) -> Result String { mod tests { use super::*; + #[test] + fn large_squid_provisioning_has_time_to_finish_without_extending_shutdown() { + let folder = tempfile::tempdir().unwrap(); + let modules = folder.path().join("Core/configs/modules"); + std::fs::create_dir_all(&modules).unwrap(); + std::fs::write(modules.join("playerbots.conf.dist"), "AiPlayerbot.Enabled = 1\n").unwrap(); + assert_eq!(Verb::StartAll.timeout(folder.path()), Duration::from_secs(1800)); + assert_eq!(Verb::StopAll.timeout(folder.path()), Duration::from_secs(240)); + std::fs::write(modules.join("playerbots.conf"), "AiPlayerbot.Enabled = 0\n").unwrap(); + assert_eq!(Verb::StartWorld.timeout(folder.path()), Duration::from_secs(420)); + } + #[test] fn translates_known_launcher_messages() { assert_eq!(translate("RuntimeError: Port 8085 is already used. Stop the other server"), ErrorCode::PortInUse);