@yetech/estra7ah 3.3.5 → 3.3.6
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.
- package/dist/estra7ah.js +39 -13
- package/package.json +1 -1
package/dist/estra7ah.js
CHANGED
|
@@ -319,29 +319,55 @@ async function downloadRunner() {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
// Start the runner executable
|
|
322
|
+
let runnerStarted = false;
|
|
322
323
|
function startRunner() {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
324
|
+
// main() may fire this more than once (missing binary + update paths); the
|
|
325
|
+
// runner must only ever be launched once, or two processes fight for the ports.
|
|
326
|
+
if (runnerStarted) return;
|
|
327
|
+
runnerStarted = true;
|
|
328
|
+
|
|
329
|
+
const spawnOnce = () => {
|
|
330
|
+
const runnerFile = getRunner();
|
|
331
|
+
const absPath = `${DIR_NAME}/${runnerFile}`;
|
|
332
|
+
const args = process.argv.slice(2);
|
|
327
333
|
|
|
328
|
-
setTimeout(() => {
|
|
329
334
|
if (process.platform !== "win32") {
|
|
330
335
|
try {
|
|
331
|
-
fs.chmodSync(
|
|
336
|
+
fs.chmodSync(absPath, "755");
|
|
332
337
|
} catch (error) {
|
|
333
338
|
console.error("Error setting permissions:", error.message);
|
|
334
339
|
}
|
|
335
340
|
}
|
|
336
341
|
|
|
337
|
-
//
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
// Spawn the binary directly (no shell) so its own path is the argv[0] — a
|
|
343
|
+
// shell wrapper would swallow exec failures as opaque /bin/sh errors. The
|
|
344
|
+
// .js runner (armv7, no pkg target) runs under the Node that launched us.
|
|
345
|
+
const isJs = runnerFile.endsWith(".js");
|
|
346
|
+
const command = isJs ? process.execPath : absPath;
|
|
347
|
+
const commandArgs = isJs ? [absPath, ...args] : args;
|
|
348
|
+
|
|
349
|
+
let runnerProcess;
|
|
350
|
+
try {
|
|
351
|
+
runnerProcess = child_process.spawn(command, commandArgs, { stdio: "inherit" });
|
|
352
|
+
} catch (error) {
|
|
353
|
+
console.error("Failed to spawn runner:", error.message);
|
|
354
|
+
return setTimeout(spawnOnce, 3000);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Without this, a spawn failure surfaces as an uncaught exception instead
|
|
358
|
+
// of a handleable event.
|
|
359
|
+
runnerProcess.on("error", (error) => {
|
|
360
|
+
console.error("Runner spawn error:", error.message);
|
|
361
|
+
});
|
|
362
|
+
runnerProcess.on("exit", (code, signal) => {
|
|
363
|
+
console.log(`Runner exited with code ${code}${signal ? " (signal " + signal + ")" : ""}`);
|
|
364
|
+
// Keep the service alive: relaunch after a short backoff instead of
|
|
365
|
+
// leaving everything down until the next manual restart.
|
|
366
|
+
setTimeout(spawnOnce, 3000);
|
|
343
367
|
});
|
|
344
|
-
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
setTimeout(spawnOnce, 1000);
|
|
345
371
|
}
|
|
346
372
|
|
|
347
373
|
// Main function
|