autopilot-code 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +10 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -138,31 +138,35 @@ function getSystemdPaths() {
138
138
  const logPath = node_path_1.default.join(GLOBAL_CONFIG_DIR, "autopilot.log");
139
139
  return { unitPath, logPath, useSystem };
140
140
  }
141
- function generateSystemdUnit(logPath, intervalSeconds) {
142
- const execPath = process.execPath;
141
+ function generateSystemdUnit(logPath, intervalSeconds, useSystem) {
142
+ const nodePath = process.execPath;
143
+ const scriptPath = node_path_1.default.resolve(process.argv[1]);
143
144
  const args = [
145
+ scriptPath,
144
146
  "service",
145
147
  "--foreground",
146
148
  "--interval-seconds", intervalSeconds,
147
149
  ];
148
150
  const user = process.env.USER || "root";
151
+ const home = process.env.HOME || "/root";
149
152
  return `[Unit]
150
153
  Description=Autopilot automated issue runner
151
154
  After=network.target
152
155
 
153
156
  [Service]
154
157
  Type=simple
155
- ExecStart=${execPath} ${args.join(" ")}
158
+ WorkingDirectory=${home}
159
+ ExecStart=${nodePath} ${args.join(" ")}
156
160
  Restart=always
157
161
  RestartSec=10
158
162
  StandardOutput=journal
159
163
  StandardError=journal
160
164
  SyslogIdentifier=autopilot
161
- ${isRoot() ? `User=${user}` : ""}
165
+ ${useSystem ? `User=${user}` : ""}
162
166
  Environment="NODE_ENV=production"
163
167
 
164
168
  [Install]
165
- WantedBy=multi-user.target
169
+ WantedBy=${useSystem ? "multi-user.target" : "default.target"}
166
170
  `;
167
171
  }
168
172
  function systemctl(cmd, args, check = false) {
@@ -195,7 +199,7 @@ function installSystemdService() {
195
199
  if (!(0, node_fs_1.existsSync)(unitDir)) {
196
200
  (0, node_fs_1.mkdirSync)(unitDir, { recursive: true });
197
201
  }
198
- const unitContent = generateSystemdUnit(logPath, intervalSeconds);
202
+ const unitContent = generateSystemdUnit(logPath, intervalSeconds, useSystem);
199
203
  (0, node_fs_1.writeFileSync)(unitPath, unitContent, { mode: 0o644 });
200
204
  console.log(`Systemd unit file created at: ${unitPath}`);
201
205
  const daemonReloadArgs = useSystem ? [] : ["--user"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autopilot-code",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "private": false,
5
5
  "description": "Repo-issue–driven autopilot runner",
6
6
  "license": "MIT",