MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / start

Function start

gateway/src/proxy.rs:241–268  ·  view source on GitHub ↗
(config: ProxyConfig, app_state: Proxy)

Source from the content-addressed store, hash-verified

239}
240
241pub fn start(config: ProxyConfig, app_state: Proxy) -> Result<()> {
242 std::thread::Builder::new()
243 .name("proxy-main".to_string())
244 .spawn(move || {
245 // Create a new single-threaded runtime
246 let rt = tokio::runtime::Builder::new_current_thread()
247 .enable_all()
248 .build()
249 .or_panic("Failed to build Tokio runtime");
250
251 let worker_rt = tokio::runtime::Builder::new_multi_thread()
252 .thread_name("proxy-worker")
253 .enable_all()
254 .worker_threads(config.workers)
255 .build()
256 .or_panic("Failed to build Tokio runtime");
257
258 // Run the proxy_main function in this runtime
259 if let Err(err) = rt.block_on(proxy_main(&worker_rt, &config, app_state)) {
260 error!(
261 "error on {}:{:?}: {err:?}",
262 config.listen_addr, config.listen_port
263 );
264 }
265 })
266 .context("Failed to spawn proxy-main thread")?;
267 Ok(())
268}
269
270#[cfg(test)]
271mod tests {

Callers 1

mainFunction · 0.70

Calls 2

proxy_mainFunction · 0.85
buildMethod · 0.45

Tested by

no test coverage detected