mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-25 17:54:34 +08:00
fix(daemon): quote ExecStart argv to handle paths with spaces on Linux
Wraps each argument in double quotes when building the systemd unit's ExecStart= line, so installs under paths containing spaces (e.g. home directories with spaces, nvm paths) no longer cause systemd to mis-tokenize the command and fail to start the service. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
969406915f
commit
affb7a50e4
1 file changed
+5
-1
@@ -184,6 +184,10 @@ function statusMacos(): ServiceStatus {
|
||||
|
||||
// ── Linux (systemd --user) ────────────────────────────────────────────
|
||||
|
||||
function escapeSystemdArg(arg: string): string {
|
||||
return '"' + arg.replace(/\\/g, '\\\\').replace(/"/g, '\\"') + '"'
|
||||
}
|
||||
|
||||
function buildUnit(options: ServiceInstallOptions): string {
|
||||
const port = options.port ?? 3110
|
||||
const host = options.host ?? '127.0.0.1'
|
||||
@@ -191,7 +195,7 @@ function buildUnit(options: ServiceInstallOptions): string {
|
||||
const args = ['start', '--no-open', '--port', String(port), '--host', host]
|
||||
if (options.token) args.push('--token', options.token)
|
||||
if (options.headless) args.push('--headless')
|
||||
const execStart = [process.execPath, cliEntry, ...args].join(' ')
|
||||
const execStart = [process.execPath, cliEntry, ...args].map(escapeSystemdArg).join(' ')
|
||||
|
||||
return `[Unit]
|
||||
Description=ChatLab daemon
|
||||
|
||||
Reference in new issue
Block a user