fix: use perry CLI for systemd service instead of script path#143
Merged
fix: use perry CLI for systemd service instead of script path#143
Conversation
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.
| [Service] | ||
| Type=simple | ||
| ExecStart=${nodePath} ${agentPath} | ||
| ExecStart=${perryPath} ${execArgs.join(' ')} |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
perry agent runwith CLI args instead ofnode /path/to/agent/index.js__dirnamewas baked in from build machine🤖 Generated with Claude Code