@clawlabz/clawnetwork 0.1.14 → 0.1.15
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/index.ts +24 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -2394,11 +2394,32 @@ export default function register(api: OpenClawApi) {
|
|
|
2394
2394
|
// Check if already running (e.g. from a previous detached start)
|
|
2395
2395
|
const state = isNodeRunning()
|
|
2396
2396
|
if (state.running) {
|
|
2397
|
-
api.logger?.info?.(`[clawnetwork] node already running (pid=${state.pid})
|
|
2397
|
+
api.logger?.info?.(`[clawnetwork] node already running (pid=${state.pid})`)
|
|
2398
|
+
|
|
2399
|
+
// Check if running binary is outdated — if so, stop + upgrade + restart
|
|
2400
|
+
if (cfg.autoDownload) {
|
|
2401
|
+
const binary = findBinary()
|
|
2402
|
+
if (binary) {
|
|
2403
|
+
const cv = getBinaryVersion(binary)
|
|
2404
|
+
if (cv && isVersionOlder(cv, MIN_NODE_VERSION)) {
|
|
2405
|
+
api.logger?.info?.(`[clawnetwork] running node ${cv} outdated (need >=${MIN_NODE_VERSION}), upgrading...`)
|
|
2406
|
+
stopNodeProcess(api)
|
|
2407
|
+
await sleep(3_000)
|
|
2408
|
+
try {
|
|
2409
|
+
const newBinary = await downloadBinary(api)
|
|
2410
|
+
initNode(newBinary, cfg.network, api)
|
|
2411
|
+
startNodeProcess(newBinary, cfg, api)
|
|
2412
|
+
api.logger?.info?.(`[clawnetwork] node upgraded and restarted`)
|
|
2413
|
+
} catch (e: unknown) {
|
|
2414
|
+
api.logger?.warn?.(`[clawnetwork] auto-upgrade failed: ${(e as Error).message}, restarting old binary`)
|
|
2415
|
+
startNodeProcess(binary, cfg, api)
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2398
2421
|
startHealthCheck(cfg, api)
|
|
2399
|
-
// Start UI dashboard (may have been lost on gateway restart)
|
|
2400
2422
|
startUiServer(cfg, api)
|
|
2401
|
-
// Still need to ensure heartbeat loop is running (may have been lost on gateway restart)
|
|
2402
2423
|
const wallet = ensureWallet(cfg.network, api)
|
|
2403
2424
|
await sleep(5_000)
|
|
2404
2425
|
await autoRegisterMiner(cfg, wallet, api)
|
package/openclaw.plugin.json
CHANGED