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

Function main

gateway/src/main.rs:232–359  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230
231#[rocket::main]
232async fn main() -> Result<()> {
233 {
234 use tracing_subscriber::{fmt, EnvFilter};
235 let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
236 fmt().with_env_filter(filter).with_ansi(false).init();
237 }
238
239 let _ = rustls::crypto::ring::default_provider().install_default();
240
241 let args = Args::parse();
242 let figment = config::load_config_figment(args.config.as_deref());
243
244 let config = figment.focus("core").extract::<Config>()?;
245
246 // Validate node_id
247 if config.sync.enabled && config.sync.node_id == 0 {
248 anyhow::bail!("node_id must be greater than 0");
249 }
250
251 config::setup_wireguard(&config.wg)?;
252
253 let tls_config = figment
254 .focus("tls")
255 .extract::<TlsConfig>()
256 .context("Failed to extract tls config")?;
257 maybe_gen_certs(&config, &tls_config)
258 .await
259 .context("Failed to generate certs")?;
260
261 #[cfg(unix)]
262 if config.set_ulimit {
263 set_max_ulimit()?;
264 }
265
266 let my_app_id = if config.debug.insecure_skip_attestation {
267 None
268 } else {
269 let dstack_client = dstack_agent().context("Failed to create dstack client")?;
270 let info = dstack_client
271 .info()
272 .await
273 .context("Failed to get app info")?;
274 Some(info.app_id)
275 };
276 let proxy_config = config.proxy.clone();
277 let pccs_url = config.pccs_url.clone();
278 let admin_enabled = config.admin.enabled;
279 let debug_config = config.debug.clone();
280 let state = Proxy::new(ProxyOptions {
281 config,
282 my_app_id,
283 tls_config,
284 })
285 .await?;
286 info!("Starting background tasks");
287 state.start_bg_tasks().await?;
288 state.lock().reconfigure()?;
289

Callers

nothing calls this directly

Calls 15

setup_wireguardFunction · 0.85
maybe_gen_certsFunction · 0.85
dstack_agentFunction · 0.85
wavekv_sync_routesFunction · 0.85
health_routesFunction · 0.85
cloneMethod · 0.80
start_bg_tasksMethod · 0.80
reconfigureMethod · 0.80
load_config_figmentFunction · 0.70
set_max_ulimitFunction · 0.70
startFunction · 0.70
app_versionFunction · 0.70

Tested by

no test coverage detected