MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / shutdown

Method shutdown

graphlite/src/session/manager.rs:305–348  ·  view source on GitHub ↗

Graceful shutdown - persist all catalogs and close all sessions

(&self)

Source from the content-addressed store, hash-verified

303
304 /// Graceful shutdown - persist all catalogs and close all sessions
305 pub fn shutdown(&self) -> Result<(), String> {
306 log::info!("SessionManager shutting down gracefully...");
307
308 // Persist all catalogs before shutdown
309 if let Ok(catalog_manager) = self.catalog_manager.write() {
310 let persist_result =
311 SESSION_RUNTIME.with(|rt| rt.block_on(catalog_manager.persist_all()));
312 if let Err(e) = persist_result {
313 log::error!("Failed to persist catalogs during shutdown: {}", e);
314 return Err(format!("Failed to persist catalogs during shutdown: {}", e));
315 }
316 log::info!("Successfully persisted all catalogs during shutdown");
317 }
318
319 // Close all active sessions across all partitions
320 for partition in &self.sessions {
321 let session_ids: Vec<String> = {
322 if let Ok(sessions) = partition.read() {
323 sessions.keys().cloned().collect()
324 } else {
325 continue;
326 }
327 };
328
329 for session_id in session_ids {
330 if let Ok(mut sessions) = partition.write() {
331 if let Some(session_arc) = sessions.remove(&session_id) {
332 if let Ok(mut session) = session_arc.write() {
333 session.deactivate();
334 }
335 }
336 }
337 }
338 }
339
340 // Shutdown storage manager to release file locks
341 if let Err(e) = self.storage_manager.shutdown() {
342 log::error!("Failed to shutdown storage manager: {}", e);
343 return Err(format!("Failed to shutdown storage manager: {}", e));
344 }
345
346 log::info!("SessionManager shutdown completed");
347 Ok(())
348 }
349}

Callers

nothing calls this directly

Calls 3

persist_allMethod · 0.80
deactivateMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected