(options: ServiceInstallOptions)
| 189 | } |
| 190 | |
| 191 | function buildUnit(options: ServiceInstallOptions): string { |
| 192 | const port = options.port ?? 3110 |
| 193 | const host = options.host ?? '127.0.0.1' |
| 194 | const cliEntry = resolveCliPath('bin/chatlab.mjs') |
| 195 | const args = ['start', '--no-open', '--port', String(port), '--host', host] |
| 196 | if (options.token) args.push('--token', options.token) |
| 197 | if (options.headless) args.push('--headless') |
| 198 | if (options.requireAuth) args.push('--require-auth') |
| 199 | const execStart = [process.execPath, cliEntry, ...args].map(escapeSystemdArg).join(' ') |
| 200 | |
| 201 | return `[Unit] |
| 202 | Description=ChatLab daemon |
| 203 | After=network.target |
| 204 | |
| 205 | [Service] |
| 206 | ExecStart=${execStart} |
| 207 | Restart=always |
| 208 | RestartSec=5 |
| 209 | StandardOutput=append:${LOG_FILE} |
| 210 | StandardError=append:${LOG_FILE} |
| 211 | |
| 212 | [Install] |
| 213 | WantedBy=default.target |
| 214 | ` |
| 215 | } |
| 216 | |
| 217 | function installLinux(options: ServiceInstallOptions): void { |
| 218 | fs.mkdirSync(SYSTEMD_DIR, { recursive: true }) |
no test coverage detected