@infernetprotocol/cli 0.1.59 → 0.1.60
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/commands/start.js +18 -2
- package/package.json +7 -7
package/commands/start.js
CHANGED
|
@@ -83,6 +83,16 @@ const DEFAULT_HEARTBEAT_MS = 30_000;
|
|
|
83
83
|
const DEFAULT_POLL_MS = 15_000;
|
|
84
84
|
const UPDATE_CHECK_MS = 5 * 60 * 1000; // 5 minutes
|
|
85
85
|
const UPDATE_DRAIN_MS = 10 * 60 * 1000; // wait for in-flight jobs before restarting
|
|
86
|
+
const SHUTDOWN_DEADLINE_MS = 5_000; // hard exit: a half-shut daemon must never outlive its pidfile
|
|
87
|
+
const OFFLINE_HEARTBEAT_TIMEOUT_MS = 3_000;
|
|
88
|
+
|
|
89
|
+
function withTimeout(promise, ms, what) {
|
|
90
|
+
let timer;
|
|
91
|
+
const timeout = new Promise((_, reject) => {
|
|
92
|
+
timer = setTimeout(() => reject(new Error(`${what} timed out after ${ms} ms`)), ms);
|
|
93
|
+
});
|
|
94
|
+
return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
|
|
95
|
+
}
|
|
86
96
|
|
|
87
97
|
async function writePidFile(pid) {
|
|
88
98
|
const p = getDaemonPidPath();
|
|
@@ -1349,10 +1359,16 @@ async function runDaemon(args, ctx) {
|
|
|
1349
1359
|
if (shuttingDown) return;
|
|
1350
1360
|
shuttingDown = true;
|
|
1351
1361
|
process.stdout.write(`\nReceived ${signal}; shutting down...\n`);
|
|
1362
|
+
// Exit no matter what hangs below. A daemon that has released its socket and pidfile but
|
|
1363
|
+
// is still alive is invisible to `infernet start`, so every restart stacked another one.
|
|
1364
|
+
setTimeout(() => {
|
|
1365
|
+
process.stderr.write(`shutdown did not finish in ${SHUTDOWN_DEADLINE_MS} ms; exiting anyway\n`);
|
|
1366
|
+
process.exit(0);
|
|
1367
|
+
}, SHUTDOWN_DEADLINE_MS);
|
|
1352
1368
|
if (heartbeatTimer) clearInterval(heartbeatTimer);
|
|
1353
1369
|
if (pollTimer) clearInterval(pollTimer);
|
|
1354
1370
|
try {
|
|
1355
|
-
await client.heartbeat({ status: 'offline' });
|
|
1371
|
+
await withTimeout(client.heartbeat({ status: 'offline' }), OFFLINE_HEARTBEAT_TIMEOUT_MS, 'offline heartbeat');
|
|
1356
1372
|
} catch (err) {
|
|
1357
1373
|
process.stderr.write(`offline heartbeat failed: ${err?.message ?? err}\n`);
|
|
1358
1374
|
}
|
|
@@ -1602,7 +1618,7 @@ async function runDaemon(args, ctx) {
|
|
|
1602
1618
|
if (ipcServer) try { ipcServer.close(); } catch {}
|
|
1603
1619
|
if (p2pServer) try { p2pServer.close(); } catch {}
|
|
1604
1620
|
if (healthServer) try { healthServer.close(); } catch {}
|
|
1605
|
-
try { await shutdownEngine(); } catch {}
|
|
1621
|
+
try { await withTimeout(shutdownEngine(), SHUTDOWN_DEADLINE_MS, 'engine shutdown'); } catch {}
|
|
1606
1622
|
removeSocketFile();
|
|
1607
1623
|
await removePidFile();
|
|
1608
1624
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infernetprotocol/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"description": "GPU-node CLI / daemon for the Infernet Protocol — register a GPU server with a Supabase control plane and start earning.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"ora": "^9.4.0",
|
|
31
31
|
"react": "^17.0.2",
|
|
32
32
|
"react-blessed": "^0.7.2",
|
|
33
|
-
"@infernetprotocol/auth": "0.1.
|
|
34
|
-
"@infernetprotocol/deploy-providers": "0.1.
|
|
35
|
-
"@infernetprotocol/engine": "0.1.
|
|
36
|
-
"@infernetprotocol/
|
|
37
|
-
"@infernetprotocol/rpc-adapter": "0.1.
|
|
38
|
-
"@infernetprotocol/
|
|
33
|
+
"@infernetprotocol/auth": "0.1.60",
|
|
34
|
+
"@infernetprotocol/deploy-providers": "0.1.60",
|
|
35
|
+
"@infernetprotocol/engine": "0.1.60",
|
|
36
|
+
"@infernetprotocol/config": "0.1.60",
|
|
37
|
+
"@infernetprotocol/rpc-adapter": "0.1.60",
|
|
38
|
+
"@infernetprotocol/gpu": "0.1.60"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|