MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / start_client_process

Function start_client_process

crates/cli/src/subcommands/dev.rs:1672–1712  ·  view source on GitHub ↗

Start the client development server as a child process. The process inherits stdout/stderr so the user can see the output. Sets SPACETIMEDB_DB_NAME and SPACETIMEDB_HOST environment variables for the client.

(
    command: &str,
    working_dir: &Path,
    database_name: &str,
    host_url: &str,
)

Source from the content-addressed store, hash-verified

1670/// The process inherits stdout/stderr so the user can see the output.
1671/// Sets SPACETIMEDB_DB_NAME and SPACETIMEDB_HOST environment variables for the client.
1672fn start_client_process(
1673 command: &str,
1674 working_dir: &Path,
1675 database_name: &str,
1676 host_url: &str,
1677) -> Result<Child, anyhow::Error> {
1678 println!("{} {}", "Starting client:".cyan(), command.dimmed());
1679
1680 if command.trim().is_empty() {
1681 anyhow::bail!("Empty client command");
1682 }
1683
1684 // Use shell to handle PATH resolution and .cmd/.bat scripts on Windows
1685 #[cfg(windows)]
1686 let child = TokioCommand::new("cmd")
1687 .args(["/C", command])
1688 .current_dir(working_dir)
1689 .env("SPACETIMEDB_DB_NAME", database_name)
1690 .env("SPACETIMEDB_HOST", host_url)
1691 .stdout(std::process::Stdio::inherit())
1692 .stderr(std::process::Stdio::inherit())
1693 .stdin(std::process::Stdio::inherit())
1694 .kill_on_drop(true)
1695 .spawn()
1696 .with_context(|| format!("Failed to start client command: {}", command))?;
1697
1698 #[cfg(not(windows))]
1699 let child = TokioCommand::new("sh")
1700 .args(["-c", command])
1701 .current_dir(working_dir)
1702 .env("SPACETIMEDB_DB_NAME", database_name)
1703 .env("SPACETIMEDB_HOST", host_url)
1704 .stdout(std::process::Stdio::inherit())
1705 .stderr(std::process::Stdio::inherit())
1706 .stdin(std::process::Stdio::inherit())
1707 .kill_on_drop(true)
1708 .spawn()
1709 .with_context(|| format!("Failed to start client command: {}", command))?;
1710
1711 Ok(child)
1712}
1713
1714#[cfg(test)]
1715mod tests {

Callers 1

execFunction · 0.85

Calls 5

stdinMethod · 0.80
newFunction · 0.50
OkFunction · 0.50
is_emptyMethod · 0.45
spawnMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…