relife2 1.0.2 → 1.0.3
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/cli.js +9 -41
- package/dist/cli.js.map +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -319,24 +319,24 @@ var RpcClient = class {
|
|
|
319
319
|
async function ensureDaemonClient() {
|
|
320
320
|
const runtime = runtimeDir();
|
|
321
321
|
const data = dataDir();
|
|
322
|
-
|
|
322
|
+
for (const dir of [runtime, data, path3.join(data, "logs"), path3.join(data, "state")]) {
|
|
323
|
+
try {
|
|
324
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
325
|
+
} catch {
|
|
326
|
+
}
|
|
327
|
+
}
|
|
323
328
|
let sock = await tryConnect(runtime);
|
|
324
329
|
if (sock !== null) {
|
|
325
330
|
return await validateClient(sock);
|
|
326
331
|
}
|
|
327
|
-
cleanStaleLockIfNeeded(runtime);
|
|
328
332
|
spawnDaemon();
|
|
329
333
|
for (let i = 0; i < 80 && sock === null; i++) {
|
|
330
334
|
await sleep(100);
|
|
331
335
|
sock = await tryConnect(runtime);
|
|
332
336
|
}
|
|
333
337
|
if (sock === null) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
for (let i = 0; i < 40 && sock === null; i++) {
|
|
337
|
-
await sleep(100);
|
|
338
|
-
sock = await tryConnect(runtime);
|
|
339
|
-
}
|
|
338
|
+
await sleep(200);
|
|
339
|
+
sock = await tryConnect(runtime);
|
|
340
340
|
}
|
|
341
341
|
if (sock === null) {
|
|
342
342
|
throw new Error(
|
|
@@ -364,38 +364,6 @@ async function validateClient(sock) {
|
|
|
364
364
|
throw err;
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
|
-
function ensureDirs(runtime, data) {
|
|
368
|
-
for (const dir of [runtime, data, path3.join(data, "logs"), path3.join(data, "state")]) {
|
|
369
|
-
try {
|
|
370
|
-
fs3.mkdirSync(dir, { recursive: true });
|
|
371
|
-
} catch {
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
function cleanStaleLockIfNeeded(runtime) {
|
|
376
|
-
const file = lockPath(runtime);
|
|
377
|
-
try {
|
|
378
|
-
const raw = fs3.readFileSync(file, "utf8");
|
|
379
|
-
const parsed = JSON.parse(raw);
|
|
380
|
-
const pid = typeof parsed.pid === "number" ? parsed.pid : null;
|
|
381
|
-
if (pid === null) {
|
|
382
|
-
fs3.unlinkSync(file);
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
try {
|
|
386
|
-
process.kill(pid, 0);
|
|
387
|
-
} catch (e) {
|
|
388
|
-
const code = e.code;
|
|
389
|
-
if (code === "ESRCH") {
|
|
390
|
-
try {
|
|
391
|
-
fs3.unlinkSync(file);
|
|
392
|
-
} catch {
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
} catch {
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
367
|
function spawnDaemon() {
|
|
400
368
|
const arg1 = process.argv[1];
|
|
401
369
|
const isSingleBinary = arg1 === void 0 || !arg1.endsWith(".js") && !arg1.endsWith(".mjs") && !arg1.endsWith(".cjs");
|
|
@@ -2397,7 +2365,7 @@ function printUsage2() {
|
|
|
2397
2365
|
}
|
|
2398
2366
|
|
|
2399
2367
|
// src/version.ts
|
|
2400
|
-
var VERSION = "1.0.
|
|
2368
|
+
var VERSION = "1.0.3";
|
|
2401
2369
|
|
|
2402
2370
|
// src/commands/help.ts
|
|
2403
2371
|
var HELP_TEXT = `relife2 ${VERSION} \u2014 process manager for Node.js & Bun apps (PM2 alternative, done right)
|