@chrysb/alphaclaw 0.1.7 → 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.
|
@@ -130,13 +130,30 @@ const createAlphaclawVersionService = () => {
|
|
|
130
130
|
);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
+
const isContainer = () =>
|
|
134
|
+
process.env.RAILWAY_ENVIRONMENT ||
|
|
135
|
+
process.env.RENDER ||
|
|
136
|
+
process.env.FLY_APP_NAME ||
|
|
137
|
+
fs.existsSync("/.dockerenv");
|
|
138
|
+
|
|
133
139
|
const restartProcess = () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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");
|
|
151
|
+
const child = spawn(process.argv[0], process.argv.slice(1), {
|
|
152
|
+
detached: true,
|
|
153
|
+
stdio: "inherit",
|
|
154
|
+
});
|
|
155
|
+
child.unref();
|
|
156
|
+
process.exit(0);
|
|
140
157
|
};
|
|
141
158
|
|
|
142
159
|
const getVersionStatus = async (refresh) => {
|