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

Function ensureService

scripts/studio-host-provider.mjs:129–153  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

127}
128
129async function ensureService(config) {
130 const status = await serviceStatus().catch(() => null);
131 if (serviceLooksUsable(status, config)) {
132 config.localUrl = status.httpUrl.replace(/\/$/, "");
133 config.localToken = status.accessToken;
134 return status;
135 }
136 const args = [
137 "service",
138 status ? "restart" : "start",
139 "--port",
140 String(new URL(config.localUrl).port || 4310),
141 "--bind",
142 "127.0.0.1",
143 "--video-codec",
144 config.videoCodec,
145 "--stream-quality",
146 config.streamQuality,
147 ];
148 await execFileAsync(simdeckBinary(), args, { timeout: 120000 });
149 const next = await serviceStatus();
150 config.localUrl = next.httpUrl.replace(/\/$/, "");
151 config.localToken = next.accessToken;
152 return next;
153}
154
155async function serviceStatus() {
156 const { stdout } = await execFileAsync(

Callers 1

runFunction · 0.85

Calls 4

serviceStatusFunction · 0.85
serviceLooksUsableFunction · 0.85
simdeckBinaryFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected