(options: ServiceInstallOptions)
| 215 | } |
| 216 | |
| 217 | function installLinux(options: ServiceInstallOptions): void { |
| 218 | fs.mkdirSync(SYSTEMD_DIR, { recursive: true }) |
| 219 | fs.mkdirSync(path.join(SYSTEM_DIR, 'logs'), { recursive: true }) |
| 220 | |
| 221 | fs.writeFileSync(SYSTEMD_SERVICE, buildUnit(options)) |
| 222 | |
| 223 | try { |
| 224 | execSync('systemctl --user daemon-reload', { stdio: 'pipe' }) |
| 225 | execSync('systemctl --user enable --now chatlab.service', { stdio: 'pipe' }) |
| 226 | } catch (err) { |
| 227 | throw new Error(`systemctl failed: ${err instanceof Error ? err.message : err}`) |
| 228 | } |
| 229 | |
| 230 | const port = options.port ?? 3110 |
| 231 | const host = options.host ?? '127.0.0.1' |
| 232 | writeMeta({ port, host, installedAt: new Date().toISOString() }) |
| 233 | |
| 234 | console.log(`\nChatLab is now running as a system service`) |
| 235 | console.log(` API: http://${host}:${port}`) |
| 236 | console.log(` Logs: ${LOG_FILE}`) |
| 237 | console.log(` Unit: ${SYSTEMD_SERVICE} (systemd)`) |
| 238 | console.log(`\nAuto-starts on login. Use \`chatlab stop\` to remove.\n`) |
| 239 | } |
| 240 | |
| 241 | function uninstallLinux(): void { |
| 242 | if (!fs.existsSync(SYSTEMD_SERVICE)) { |
no test coverage detected