@chrysb/alphaclaw 0.1.6 → 0.1.8

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.
@@ -1,5 +1,4 @@
1
1
  const { exec } = require("child_process");
2
- const { spawn } = require("child_process");
3
2
  const fs = require("fs");
4
3
  const path = require("path");
5
4
  const https = require("https");
@@ -131,8 +130,24 @@ const createAlphaclawVersionService = () => {
131
130
  );
132
131
  });
133
132
 
133
+ const isContainer = () =>
134
+ process.env.RAILWAY_ENVIRONMENT ||
135
+ process.env.RENDER ||
136
+ process.env.FLY_APP_NAME ||
137
+ fs.existsSync("/.dockerenv");
138
+
134
139
  const restartProcess = () => {
135
- console.log("[alphaclaw] Restarting process...");
140
+ if (isContainer()) {
141
+ // In containers, exit with code 1 so the orchestrator (Railway, Docker
142
+ // restart policy, etc.) treats it as a crash and restarts the service.
143
+ // Spawning a child doesn't work because killing PID 1 tears down the
144
+ // entire container along with any children.
145
+ console.log("[alphaclaw] Restarting via container crash (exit 1)...");
146
+ process.exit(1);
147
+ }
148
+ // On bare metal / Mac / Linux, spawn a replacement process then exit.
149
+ console.log("[alphaclaw] Spawning new process and exiting...");
150
+ const { spawn } = require("child_process");
136
151
  const child = spawn(process.argv[0], process.argv.slice(1), {
137
152
  detached: true,
138
153
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrysb/alphaclaw",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },