MCPcopy Create free account
hub / github.com/JaredStewart/coderlm / run_server

Function run_server

server/src/main.rs:76–109  ·  view source on GitHub ↗
(
    path: Option<PathBuf>,
    port: u16,
    bind: String,
    max_file_size: u64,
    max_projects: usize,
)

Source from the content-addressed store, hash-verified

74}
75
76async fn run_server(
77 path: Option<PathBuf>,
78 port: u16,
79 bind: String,
80 max_file_size: u64,
81 max_projects: usize,
82) -> anyhow::Result<()> {
83 // Create shared state
84 let state = AppState::new(max_projects, max_file_size);
85
86 // If an initial path was provided, pre-index it
87 if let Some(ref p) = path {
88 info!("Pre-indexing project: {}", p.display());
89 state.get_or_create_project(p).map_err(|e| {
90 anyhow::anyhow!("Failed to index '{}': {}", p.display(), e)
91 })?;
92 }
93
94 // Build router
95 let app = server::build_router(state);
96
97 let addr = format!("{}:{}", bind, port);
98 let listener = tokio::net::TcpListener::bind(&addr).await?;
99
100 if let Some(ref p) = path {
101 info!("coderlm serving {} on http://{}", p.display(), addr);
102 } else {
103 info!("coderlm server listening on http://{} (no project pre-indexed)", addr);
104 }
105
106 axum::serve(listener, app).await?;
107
108 Ok(())
109}

Callers 1

mainFunction · 0.85

Calls 2

build_routerFunction · 0.85
get_or_create_projectMethod · 0.80

Tested by

no test coverage detected