MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / start_project_service

Function start_project_service

packages/server/src/main.rs:1327–1505  ·  view source on GitHub ↗
(options: ServiceLaunchOptions)

Source from the content-addressed store, hash-verified

1325}
1326
1327fn start_project_service(options: ServiceLaunchOptions) -> anyhow::Result<ServiceMetadata> {
1328 let project_root = project_root()?;
1329 let metadata_path = service_metadata_path()?;
1330 let log_path = service_log_path()?;
1331 if let Some(parent) = log_path.parent() {
1332 fs::create_dir_all(parent)
1333 .with_context(|| format!("create service log directory {}", parent.display()))?;
1334 }
1335 let port = if options.allow_port_probe {
1336 choose_available_service_port_for_bind(options.port, options.bind)?
1337 } else {
1338 choose_service_port_for_bind(options.port, options.bind)?
1339 };
1340 let access_token = auth::generate_access_token();
1341 let pairing_code = auth::generate_pairing_code();
1342 let executable = current_simdeck_executable_path()?;
1343 let mut args = vec![
1344 "service".to_owned(),
1345 "run".to_owned(),
1346 "--metadata-path".to_owned(),
1347 metadata_path.to_string_lossy().into_owned(),
1348 "--port".to_owned(),
1349 port.to_string(),
1350 "--bind".to_owned(),
1351 options.bind.to_string(),
1352 "--access-token".to_owned(),
1353 access_token.clone(),
1354 "--pairing-code".to_owned(),
1355 pairing_code.clone(),
1356 "--video-codec".to_owned(),
1357 options.video_codec.as_env_value().to_owned(),
1358 "--android-gpu".to_owned(),
1359 options.android_gpu.as_emulator_value().to_owned(),
1360 "--server-kind".to_owned(),
1361 "standalone".to_owned(),
1362 ];
1363 if options.low_latency {
1364 args.push("--low-latency".to_owned());
1365 }
1366 if let Some(local_stream_fps) = options.local_stream_fps {
1367 args.push("--local-stream-fps".to_owned());
1368 args.push(local_stream_fps.to_string());
1369 }
1370 if let Some(advertise_host) = &options.advertise_host {
1371 args.push("--advertise-host".to_owned());
1372 args.push(advertise_host.clone());
1373 }
1374 if let Some(client_root) = &options.client_root {
1375 args.push("--client-root".to_owned());
1376 args.push(client_root.to_string_lossy().into_owned());
1377 }
1378 let stream_quality_env = options
1379 .stream_quality_profile
1380 .as_deref()
1381 .map(stream_quality_env_for_profile)
1382 .transpose()?;
1383
1384 let log_stdout = fs::OpenOptions::new()

Callers 1

Calls 15

project_rootFunction · 0.85
service_metadata_pathFunction · 0.85
service_log_pathFunction · 0.85
generate_access_tokenFunction · 0.85
generate_pairing_codeFunction · 0.85
now_secsFunction · 0.85
write_service_metadataFunction · 0.85
wait_for_serviceFunction · 0.85
openMethod · 0.80

Tested by

no test coverage detected