1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Server management module for MCP Runner.
//!
//! This module handles the lifecycle, monitoring, and process management of MCP servers.
//! It provides functionality to start, stop, and monitor the health of MCP server processes.
//! All public components are instrumented with `tracing` spans.
//!
//! # Components
//!
//! * `lifecycle` - Manages server lifecycle events and statuses
//! * `monitor` - Health monitoring and automatic recovery of servers
//! * `process` - Core process management for server instances
//!
//! # Examples
//!
//! Managing server lifecycle:
//!
//! ```no_run
//! use mcp_runner::server::{ServerLifecycleManager, ServerLifecycleEvent, ServerProcess};
//! use mcp_runner::config::ServerConfig;
//! use std::sync::Arc;
//! use std::collections::HashMap;
//!
//! // Create a server process to get a valid ServerId
//! let config = ServerConfig {
//! command: "sample".to_string(),
//! args: vec![],
//! env: HashMap::new(),
//! };
//! let server_process = ServerProcess::new("fetch-server".to_string(), config);
//! let server_id = server_process.id();
//! let server_name = "fetch-server".to_string();
//!
//! // Create lifecycle manager and record an event
//! let manager = Arc::new(ServerLifecycleManager::new());
//! manager.record_event(
//! server_id,
//! server_name,
//! ServerLifecycleEvent::Started,
//! Some("Server started successfully".to_string())
//! ).unwrap();
//! ```
//!
//! Monitoring server health:
//!
//! ```no_run
//! use mcp_runner::server::{ServerMonitor, ServerMonitorConfig, ServerLifecycleManager};
//! use std::sync::Arc;
//! use std::time::Duration;
//!
//! let lifecycle_manager = Arc::new(ServerLifecycleManager::new());
//! let config = ServerMonitorConfig {
//! check_interval: Duration::from_secs(30),
//! health_check_timeout: Duration::from_secs(5),
//! auto_restart: true,
//! max_consecutive_failures: 3,
//! };
//!
//! // Create and start the monitor
//! let mut monitor = ServerMonitor::new(lifecycle_manager, config);
//! monitor.start().unwrap();
//! ```
pub use ;
pub use ;
pub use ;