fix(server): return version details in health and shutdown endpoints
This commit is contained in:
1 parent
4cb76725fe
commit
cb39f94584
4 files changed
+35
-11
No files matched your search
+10
-2
@@ -104,8 +104,16 @@ pub async fn gate_set_handler(
|
||||
Ok((axum::http::StatusCode::OK, "Gate state updated."))
|
||||
}
|
||||
|
||||
pub async fn health_handler() -> &'static str {
|
||||
"OK"
|
||||
pub async fn health_handler() -> impl IntoResponse {
|
||||
axum::Json(serde_json::json!({
|
||||
"status": "ok",
|
||||
"version": {
|
||||
"app_version": env!("APP_VERSION"),
|
||||
"cargo_pkg_version": env!("CARGO_PKG_VERSION"),
|
||||
"target_os": std::env::consts::OS,
|
||||
"target_arch": std::env::consts::ARCH,
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+11
-1
@@ -143,7 +143,17 @@ pub fn create_router(app_state: Arc<AppState>) -> Router {
|
||||
std::process::exit(0);
|
||||
});
|
||||
|
||||
(axum::http::StatusCode::OK, "Shutting down...").into_response()
|
||||
axum::Json(serde_json::json!({
|
||||
"status": "shutting_down",
|
||||
"message": "MCP Memory Server gracefully shutting down.",
|
||||
"version_details": {
|
||||
"app_version": env!("APP_VERSION"),
|
||||
"cargo_pkg_version": env!("CARGO_PKG_VERSION"),
|
||||
"target_os": std::env::consts::OS,
|
||||
"target_arch": std::env::consts::ARCH,
|
||||
"shutdown_checkpoint": format!("chk_shutdown_{}", now)
|
||||
}
|
||||
})).into_response()
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1142,12 +1142,18 @@
|
||||
if (!feed) return;
|
||||
feed.innerHTML = '';
|
||||
|
||||
// Sort history by timestamp descending so newest entries are at top
|
||||
const sorted = [...history].sort((a, b) => {
|
||||
const tA = (typeof a === 'object' && a) ? (a.timestamp || a.time || 0) : 0;
|
||||
const tB = (typeof b === 'object' && b) ? (b.timestamp || b.time || 0) : 0;
|
||||
return tB - tA;
|
||||
});
|
||||
// Helper to normalize timestamp to epoch milliseconds
|
||||
const getMillis = (item) => {
|
||||
if (!item || typeof item !== 'object') return 0;
|
||||
let val = item.timestamp || item.time || item.updated_at || 0;
|
||||
if (typeof val === 'number' && val < 10000000000) {
|
||||
val = val * 1000;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
// Sort history by normalized timestamp descending so newest entries are always at top
|
||||
const sorted = [...history].sort((a, b) => getMillis(b) - getMillis(a));
|
||||
|
||||
sorted.forEach(item => {
|
||||
const div = document.createElement('div');
|
||||
@@ -1396,7 +1402,7 @@
|
||||
const data = await res.json();
|
||||
const verEl = document.getElementById('app-version');
|
||||
if (verEl) {
|
||||
verEl.textContent = `v${data.version}`;
|
||||
verEl.innerHTML = `<span style="background:var(--card-bg); border:1px solid var(--border-color); color:var(--text-secondary); padding:3px 10px; border-radius:12px; font-size:0.85em; font-weight:600; font-family:monospace;">v${data.version}</span>`;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to load version", err);
|
||||
|
||||
Reference in new issue
Block a user