(config)
| 127 | } |
| 128 | |
| 129 | async 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 | |
| 155 | async function serviceStatus() { |
| 156 | const { stdout } = await execFileAsync( |
no test coverage detected