@decentnetwork/beagle 0.1.57 → 0.1.58
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 +3 -0
- package/dist/desktop/app.js +1 -1
- package/dist/peer-host.d.ts +2 -0
- package/dist/peer-host.js +29 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -28,6 +28,7 @@ function parseArgs(argv) {
|
|
|
28
28
|
" --config-dir <p> identity/config dir (default ~/.agentnet)",
|
|
29
29
|
" --dora-dir <p> dora roster dir, if this machine runs a dora",
|
|
30
30
|
" --backend <k> force 'daemon' or 'embedded' (default: auto)",
|
|
31
|
+
" --wait-daemon <s> with --backend daemon, wait this long for it (default 60)",
|
|
31
32
|
" -h, --help this text",
|
|
32
33
|
].join("\n"));
|
|
33
34
|
process.exit(0);
|
|
@@ -40,6 +41,7 @@ function parseArgs(argv) {
|
|
|
40
41
|
configDir: get("--config-dir") ?? defaultConfigDir(),
|
|
41
42
|
doraDir: get("--dora-dir"),
|
|
42
43
|
backend: get("--backend"),
|
|
44
|
+
waitDaemon: get("--wait-daemon"),
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
const readJsonVer = (file) => {
|
|
@@ -109,6 +111,7 @@ async function main() {
|
|
|
109
111
|
onAutoAcceptChange: (enabled) => saveAutoAccept(args.configDir, enabled),
|
|
110
112
|
peerVersion: resolveVer("@decentnetwork/peer"),
|
|
111
113
|
force: args.backend,
|
|
114
|
+
waitForDaemonMs: args.waitDaemon ? Number(args.waitDaemon) * 1000 : undefined,
|
|
112
115
|
}));
|
|
113
116
|
}
|
|
114
117
|
catch (error) {
|
package/dist/desktop/app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
window.__DK_UI_VERSION="0.1.
|
|
1
|
+
window.__DK_UI_VERSION="0.1.58";
|
|
2
2
|
const ICON_PATHS = {
|
|
3
3
|
// ---- tab bar (the four must feel like one set) ----
|
|
4
4
|
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>',
|
package/dist/peer-host.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface OpenPeerHostOptions {
|
|
|
46
46
|
/** Force a backend instead of auto-detecting. Mainly for testing the
|
|
47
47
|
* embedded path on a machine that also runs a daemon. */
|
|
48
48
|
force?: BackendKind;
|
|
49
|
+
/** How long `force: "daemon"` waits for the daemon socket. Default 60s. */
|
|
50
|
+
waitForDaemonMs?: number;
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* Pick a backend.
|
package/dist/peer-host.js
CHANGED
|
@@ -77,7 +77,35 @@ export async function openPeerHost(opts) {
|
|
|
77
77
|
return { host: new DaemonHost(dataDir), why: `decentlan daemon at ${dataDir}` };
|
|
78
78
|
}
|
|
79
79
|
if (opts.force === "daemon") {
|
|
80
|
-
|
|
80
|
+
// Wait rather than die.
|
|
81
|
+
//
|
|
82
|
+
// A supervised beagle (pm2, systemd) routinely starts BEFORE the daemon it
|
|
83
|
+
// is meant to attach to. Throwing there turned a boot-order race into a
|
|
84
|
+
// permanent problem: beagle fell back to embedded, took <dataDir>/daemon.pid,
|
|
85
|
+
// and from then on `agentnet service restart` refused to start the daemon
|
|
86
|
+
// because a live process already held the identity — which is why upgrading
|
|
87
|
+
// needed a pm2 stop / restart / pm2 start dance instead of one command.
|
|
88
|
+
//
|
|
89
|
+
// Explicit --backend daemon means "this box's identity belongs to the
|
|
90
|
+
// daemon". Honour that by waiting for it to appear.
|
|
91
|
+
const waitMs = Math.max(0, opts.waitForDaemonMs ?? 60_000);
|
|
92
|
+
const deadline = Date.now() + waitMs;
|
|
93
|
+
let waited = false;
|
|
94
|
+
while (!daemonIsRunning(dataDir)) {
|
|
95
|
+
if (Date.now() >= deadline) {
|
|
96
|
+
throw new Error(`--backend daemon was requested but no decentlan daemon appeared within ${Math.round(waitMs / 1000)}s ` +
|
|
97
|
+
`(looked for ${ipcSocketPath(dataDir)}).`);
|
|
98
|
+
}
|
|
99
|
+
if (!waited) {
|
|
100
|
+
waited = true;
|
|
101
|
+
console.log(`waiting up to ${Math.round(waitMs / 1000)}s for the decentlan daemon at ${ipcSocketPath(dataDir)}…`);
|
|
102
|
+
}
|
|
103
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
host: new DaemonHost(dataDir),
|
|
107
|
+
why: waited ? `decentlan daemon at ${dataDir} (after waiting)` : `decentlan daemon at ${dataDir}`,
|
|
108
|
+
};
|
|
81
109
|
}
|
|
82
110
|
// Reuse decentlan's identity when it exists so friends carry over — this is
|
|
83
111
|
// the same node, not a new one. The daemon is not running, so nothing else
|
package/package.json
CHANGED