Skip to content

fix: use perry CLI for systemd service instead of script path#143

Merged
gricha merged 1 commit intomainfrom
fix/systemd-exec-path
Jan 22, 2026
Merged

fix: use perry CLI for systemd service instead of script path#143
gricha merged 1 commit intomainfrom
fix/systemd-exec-path

Conversation

@gricha
Copy link
Copy Markdown
Owner

@gricha gricha commented Jan 22, 2026

Summary

  • Use perry agent run with CLI args instead of node /path/to/agent/index.js
  • Fixes systemd service not starting because __dirname was baked in from build machine
  • Pass port/config-dir/no-host-access as CLI flags instead of env vars

🤖 Generated with Claude Code

The previous approach used `node /path/to/agent/index.js` but when perry
is compiled as a single binary, __dirname gets baked in from the build
environment (e.g., /home/runner/work/perry/...) which doesn't exist on
the target machine.

Now uses `perry agent run` with CLI arguments instead, which works
correctly for compiled binaries.
Comment thread src/agent/systemd.ts
[Service]
Type=simple
ExecStart=${nodePath} ${agentPath}
ExecStart=${perryPath} ${execArgs.join(' ')}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The ExecStart command for the systemd service is built without quoting arguments. This will cause paths with spaces to be parsed incorrectly by systemd, leading to service failure.
Severity: MEDIUM

Suggested Fix

The arguments in execArgs should be individually quoted before being joined to form the ExecStart string. For example, by mapping over the array: execArgs.map(arg => "${arg}").join(' '). This ensures that systemd treats each argument, including paths with spaces, as a single unit.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/agent/systemd.ts#L51

Potential issue: The code at `src/agent/systemd.ts:51` constructs the `ExecStart` line
for a systemd service by joining arguments with a space. However, it does not quote the
arguments. If a user provides a path with spaces for the `--config-dir` option (e.g.,
`/home/user/my config`), the resulting `ExecStart` line will be parsed incorrectly by
systemd. Systemd will split the path at the space, passing an incomplete path
(`/home/user/my`) to the `perry` agent. This will cause the service to start with the
wrong configuration or fail to start entirely.

Did we get this right? 👍 / 👎 to inform future reviews.

@gricha gricha merged commit 4ad017f into main Jan 22, 2026
8 checks passed
@gricha gricha deleted the fix/systemd-exec-path branch January 22, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant