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

Function main

supervisor/src/main.rs:75–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75fn main() -> Result<()> {
76 // Set max ulimit for file descriptors
77 #[cfg(unix)]
78 if let Err(err) = set_max_ulimit() {
79 error!("Failed to set max ulimit: {err:?}");
80 }
81
82 let args = Args::parse();
83 if let Some(log_file) = &args.log_file {
84 mk_parents(log_file)?;
85 let file = std::fs::OpenOptions::new()
86 .create(true)
87 .append(true)
88 .open(log_file)
89 .context("Failed to open log file")?;
90 tracing_subscriber::fmt()
91 .with_env_filter(EnvFilter::from_default_env())
92 .with_writer(file)
93 .with_ansi(false)
94 .init();
95 } else {
96 tracing_subscriber::fmt()
97 .with_env_filter(EnvFilter::from_default_env())
98 .with_ansi(false)
99 .init();
100 }
101 #[cfg(unix)]
102 if args.detach {
103 // run in background
104 let ret = unsafe { libc::daemon(1, 0) };
105 if ret != 0 {
106 error!("Failed to run in background, error code: {ret}");
107 bail!("Failed to run in background, error code: {ret}");
108 }
109 }
110 if let Err(err) = async_main(args) {
111 error!("{err:?}");
112 return Err(err);
113 }
114 Ok(())
115}
116
117#[tokio::main]
118async fn async_main(args: Args) -> Result<()> {

Callers

nothing calls this directly

Calls 5

mk_parentsFunction · 0.85
async_mainFunction · 0.85
appendMethod · 0.80
createMethod · 0.80
set_max_ulimitFunction · 0.70

Tested by

no test coverage detected