@yetech/estra7ah 3.3.4 → 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.
Files changed (2) hide show
  1. package/dist/estra7ah.js +46 -17
  2. package/package.json +1 -1
package/dist/estra7ah.js CHANGED
@@ -12,10 +12,13 @@ const ProgressBar = require("progress");
12
12
  const child_process = require("child_process");
13
13
 
14
14
  const YETECH_URL = `http://premium.yetech.co:80`;
15
- // Cloudflare-cached mirror of /runner/* (origin = same VPS). The ?v= query
16
- // string busts the edge cache exactly when a new build lands, so stale
17
- // binaries are impossible and no cache purging is ever needed.
18
- const CDN_URL = `https://dl.yetech.co`;
15
+ // Cloudflare-cached mirror of /runner/* (origin = same VPS). Plain HTTP on
16
+ // purpose: the origin is HTTP-only, and download integrity is enforced by the
17
+ // content-length size check, so TLS to the edge buys nothing here while
18
+ // avoiding the origin-cert / SSL-mode requirement. The ?v= query string busts
19
+ // the edge cache exactly when a new build lands, so stale binaries are
20
+ // impossible and no cache purging is ever needed.
21
+ const CDN_URL = `http://dl.yetech.co`;
19
22
  const RUNNERS = {
20
23
  win64: "runner-win-x64.exe",
21
24
  linux64: "runner-linux-x64",
@@ -316,29 +319,55 @@ async function downloadRunner() {
316
319
  }
317
320
 
318
321
  // Start the runner executable
322
+ let runnerStarted = false;
319
323
  function startRunner() {
320
- const runnerFile = getRunner();
321
- const runnerPath = `"${DIR_NAME}/${runnerFile}"`;
322
- const args = process.argv.slice(2);
323
- const options = { stdio: "inherit", shell: true };
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);
324
333
 
325
- setTimeout(() => {
326
334
  if (process.platform !== "win32") {
327
335
  try {
328
- fs.chmodSync(`${DIR_NAME}/${runnerFile}`, "755");
336
+ fs.chmodSync(absPath, "755");
329
337
  } catch (error) {
330
338
  console.error("Error setting permissions:", error.message);
331
339
  }
332
340
  }
333
341
 
334
- // .js runner (armv7) runs under the same Node that launched us
335
- const command = runnerFile.endsWith(".js") ? `"${process.execPath}"` : runnerPath;
336
- const commandArgs = runnerFile.endsWith(".js") ? [runnerPath, ...args] : args;
337
- const runnerProcess = child_process.spawn(command, commandArgs, options);
338
- runnerProcess.on("exit", (code) => {
339
- console.log(`Runner exited with code ${code}`);
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);
340
367
  });
341
- }, 1000);
368
+ };
369
+
370
+ setTimeout(spawnOnce, 1000);
342
371
  }
343
372
 
344
373
  // Main function
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yetech/estra7ah",
3
- "version": "3.3.4",
3
+ "version": "3.3.6",
4
4
  "description": "Estra7ah Manager",
5
5
  "author": "Abdullah Al-taheri",
6
6
  "keywords": [