MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / run_server_command

Function run_server_command

crates/opencode-cli/src/main.rs:1853–1877  ·  view source on GitHub ↗
(
    mode: &str,
    port: u16,
    hostname: String,
    mdns: bool,
    mdns_domain: String,
    cors: Vec<String>,
)

Source from the content-addressed store, hash-verified

1851}
1852
1853async fn run_server_command(
1854 mode: &str,
1855 port: u16,
1856 hostname: String,
1857 mdns: bool,
1858 mdns_domain: String,
1859 cors: Vec<String>,
1860) -> anyhow::Result<()> {
1861 if std::env::var("OPENCODE_SERVER_PASSWORD").is_err() {
1862 eprintln!("Warning: OPENCODE_SERVER_PASSWORD is not set; server is unsecured.");
1863 }
1864
1865 let bind_host = if mdns && hostname == "127.0.0.1" {
1866 "0.0.0.0".to_string()
1867 } else {
1868 hostname
1869 };
1870 let bind_port = if port == 0 { 3000 } else { port };
1871 opencode_server::set_cors_whitelist(cors);
1872 let _mdns_publisher = start_mdns_publisher_if_needed(mdns, &bind_host, bind_port, &mdns_domain);
1873 let addr: SocketAddr = format!("{}:{}", bind_host, bind_port).parse()?;
1874 println!("Starting OpenCode {} server on {}", mode, addr);
1875 opencode_server::run_server(addr).await?;
1876 Ok(())
1877}
1878
1879fn try_open_browser(url: &str) {
1880 let mut candidates: Vec<Vec<String>> = Vec::new();

Callers 3

mainFunction · 0.85
run_web_commandFunction · 0.85
run_acp_commandFunction · 0.85

Calls 4

set_cors_whitelistFunction · 0.85
run_serverFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected