feat: 完善本地MCP与扩展市场能力
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
server:
|
||||
host: 0.0.0.0
|
||||
port: 8080
|
||||
port: 18020
|
||||
log:
|
||||
level: info
|
||||
path: logs
|
||||
retain_days: 5
|
||||
runtime:
|
||||
warm_up_on_start: false
|
||||
mirror:
|
||||
npm_registry: ""
|
||||
pypi_index_url: ""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
server:
|
||||
# The port to listen on for incoming connections
|
||||
port: 8085
|
||||
port: 18020
|
||||
# The log level to use
|
||||
log:
|
||||
level: debug
|
||||
@@ -8,6 +8,10 @@ log:
|
||||
path: logs
|
||||
# The number of log files to retain (default: 5)
|
||||
retain_days: 5
|
||||
runtime:
|
||||
# Warm up uv/deno dependencies on service startup.
|
||||
# Keep this disabled to avoid repeated dependency checks/downloads at startup.
|
||||
warm_up_on_start: false
|
||||
mirror:
|
||||
npm_registry: ""
|
||||
pypi_index_url: ""
|
||||
|
||||
@@ -24,6 +24,8 @@ pub struct AppConfig {
|
||||
pub log: LogConfig,
|
||||
#[serde(default)]
|
||||
pub mirror: MirrorYamlConfig,
|
||||
#[serde(default)]
|
||||
pub runtime: RuntimeConfig,
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
@@ -43,6 +45,14 @@ pub struct LogConfig {
|
||||
pub retain_days: u32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone, Default)]
|
||||
pub struct RuntimeConfig {
|
||||
/// Warm up uv/deno dependencies when the proxy service starts.
|
||||
#[serde(default)]
|
||||
pub warm_up_on_start: bool,
|
||||
}
|
||||
|
||||
/// Default log files to retain
|
||||
fn default_retain_days() -> u32 {
|
||||
5
|
||||
@@ -89,6 +99,13 @@ impl AppConfig {
|
||||
config.log.level = log_level;
|
||||
}
|
||||
|
||||
if let Ok(warm_up_on_start) = env::var("MCP_PROXY_WARM_UP_ON_START") {
|
||||
config.runtime.warm_up_on_start = matches!(
|
||||
warm_up_on_start.to_lowercase().as_str(),
|
||||
"1" | "true" | "yes" | "on"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
|
||||
@@ -209,6 +209,10 @@ async fn run_server_mode() -> Result<()> {
|
||||
tracing::info!(" - Log directory: {}", log_path);
|
||||
tracing::info!(" - Log level: {}", &app_config.log.level);
|
||||
tracing::info!(" - Log retention days: {}", retain_days);
|
||||
tracing::info!(
|
||||
" - Warm up on start: {}",
|
||||
app_config.runtime.warm_up_on_start
|
||||
);
|
||||
tracing::info!("Environment overrides:");
|
||||
if std::env::var("MCP_PROXY_PORT").is_ok() {
|
||||
tracing::info!(" - MCP_PROXY_PORT override detected: {}", server_port);
|
||||
@@ -219,6 +223,12 @@ async fn run_server_mode() -> Result<()> {
|
||||
if let Ok(level) = std::env::var("MCP_PROXY_LOG_LEVEL") {
|
||||
tracing::info!(" - MCP_PROXY_LOG_LEVEL override detected: {}", level);
|
||||
}
|
||||
if let Ok(warm_up_on_start) = std::env::var("MCP_PROXY_WARM_UP_ON_START") {
|
||||
tracing::info!(
|
||||
" - MCP_PROXY_WARM_UP_ON_START override detected: {}",
|
||||
warm_up_on_start
|
||||
);
|
||||
}
|
||||
tracing::info!("========================================");
|
||||
|
||||
// 监听地址
|
||||
@@ -286,14 +296,18 @@ async fn run_server_mode() -> Result<()> {
|
||||
}));
|
||||
});
|
||||
|
||||
// 预热 uv/deno 环境依赖
|
||||
tokio::spawn(async move {
|
||||
info!("Warming up uv/deno runtime dependencies...");
|
||||
match warm_up_all_envs(None, None, None, None).await {
|
||||
Ok(_) => info!("Runtime dependency warm-up completed"),
|
||||
Err(e) => error!("Runtime dependency warm-up failed: {e}"),
|
||||
}
|
||||
});
|
||||
// 预热 uv/deno 环境依赖。默认关闭,避免每次服务启动都触发依赖检查/下载。
|
||||
if app_config.runtime.warm_up_on_start {
|
||||
tokio::spawn(async move {
|
||||
info!("Warming up uv/deno runtime dependencies...");
|
||||
match warm_up_all_envs(None, None, None, None).await {
|
||||
Ok(_) => info!("Runtime dependency warm-up completed"),
|
||||
Err(e) => error!("Runtime dependency warm-up failed: {e}"),
|
||||
}
|
||||
});
|
||||
} else {
|
||||
info!("Runtime dependency warm-up skipped");
|
||||
}
|
||||
|
||||
// 启动服务器,监听多种信号以实现优雅关闭
|
||||
info!("Starting HTTP server...");
|
||||
|
||||
Reference in New Issue
Block a user