//! What release this daemon is, and which run of it. //! //! Two facts ride `GET /api/info` so clients can render a status indicator and //! survive an upgrade: //! //! * [`build_info`] — the commit the binary was compiled from, stamped by //! `build.rs`. Shown in the indicator's tooltip; a change across a reconnect //! means the operator upgraded, so a browser reloads its assets. //! * [`instance_id`] — a fresh id per daemon process. A change with the same //! commit means a plain restart, which clients ride out silently. use std::sync::OnceLock; use maestro_protocol::BuildInfo; /// The commit this binary was built from. Every field is empty when the build /// happened outside a git checkout and no `MAESTRO_BUILD_*` override was given. pub fn build_info() -> BuildInfo { BuildInfo { commit: env!("MAESTRO_BUILD_COMMIT").to_string(), commit_date: env!("MAESTRO_BUILD_DATE").to_string(), dirty: env!("MAESTRO_BUILD_DIRTY") == "true", } } /// Identity of this daemon process, stable for its lifetime and different on /// every start. Clients diff it across a reconnect to detect a restart. pub fn instance_id() -> &'static str { static ID: OnceLock = OnceLock::new(); ID.get_or_init(|| uuid::Uuid::new_v4().to_string()) }