@kvbox/server 0.5.42 → 0.5.43
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/kvbox-server.js +73 -45
- package/dist/kvbox-server.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox-server.js
CHANGED
|
@@ -1176,11 +1176,32 @@ var isCaLine = (line) => /^cert-authority(,|\s)/.test(line.trim());
|
|
|
1176
1176
|
// src/core/exec.ts
|
|
1177
1177
|
import { execFile } from "node:child_process";
|
|
1178
1178
|
import { promisify } from "node:util";
|
|
1179
|
+
|
|
1180
|
+
// src/core/log.ts
|
|
1181
|
+
function formatLine(level, message, at = /* @__PURE__ */ new Date()) {
|
|
1182
|
+
return `[${at.toISOString()}][${level}]: ${message}`;
|
|
1183
|
+
}
|
|
1184
|
+
var log = {
|
|
1185
|
+
debug(message) {
|
|
1186
|
+
console.error(formatLine("debug", message));
|
|
1187
|
+
},
|
|
1188
|
+
info(message) {
|
|
1189
|
+
console.log(formatLine("info", message));
|
|
1190
|
+
},
|
|
1191
|
+
warn(message) {
|
|
1192
|
+
console.error(formatLine("warn", message));
|
|
1193
|
+
},
|
|
1194
|
+
error(message) {
|
|
1195
|
+
console.error(formatLine("error", message));
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// src/core/exec.ts
|
|
1179
1200
|
var execFileAsync = promisify(execFile);
|
|
1180
1201
|
async function run(argv, opts = {}) {
|
|
1181
1202
|
const [cmd, ...args] = opts.sudo ? ["sudo", "-n", ...argv] : argv;
|
|
1182
1203
|
if (!cmd) throw new KvboxError("run: empty argv");
|
|
1183
|
-
if (process.env["KVBOX_DEBUG"])
|
|
1204
|
+
if (process.env["KVBOX_DEBUG"]) log.debug(`exec ${[cmd, ...args].join(" ")}`);
|
|
1184
1205
|
try {
|
|
1185
1206
|
const { stdout, stderr } = await execFileAsync(cmd, args, {
|
|
1186
1207
|
cwd: opts.cwd,
|
|
@@ -2002,7 +2023,7 @@ async function readOwnerEnv(owner, p = paths()) {
|
|
|
2002
2023
|
async function envForBoot(box, p = paths()) {
|
|
2003
2024
|
const env = await readOwnerEnv(box.owner, p).catch(() => null);
|
|
2004
2025
|
const own = await readBoxEnv(box, p).catch((err) => {
|
|
2005
|
-
|
|
2026
|
+
log.warn(`box ${shown(box)}: its own variables are unreadable, it boots without them: ${err.message}`);
|
|
2006
2027
|
return [];
|
|
2007
2028
|
});
|
|
2008
2029
|
const slug = env?.vars ?? (realmOf(box.owner) !== null ? [] : null);
|
|
@@ -2299,7 +2320,7 @@ function recordVolume(meta, by, p, at = (/* @__PURE__ */ new Date()).toISOString
|
|
|
2299
2320
|
try {
|
|
2300
2321
|
insertVolumeEvent({ volumeId: meta.id, owner: meta.owner, name: meta.name, at, sizeGib: meta.sizeGib, by }, p);
|
|
2301
2322
|
} catch (err) {
|
|
2302
|
-
|
|
2323
|
+
log.warn(`volume ledger: ${err.message}`);
|
|
2303
2324
|
}
|
|
2304
2325
|
}
|
|
2305
2326
|
async function attachments(owner, p) {
|
|
@@ -2340,7 +2361,7 @@ async function listVolumes(scope, p = paths()) {
|
|
|
2340
2361
|
}
|
|
2341
2362
|
out.push(toVolume(meta, attached.get(meta.name) ?? null, p));
|
|
2342
2363
|
} catch (err) {
|
|
2343
|
-
|
|
2364
|
+
log.warn(`skipping volumes/${ref.owner}/${ref.name}: ${err.message}`);
|
|
2344
2365
|
}
|
|
2345
2366
|
}
|
|
2346
2367
|
return out.sort((a, b) => a.owner.localeCompare(b.owner) || a.name.localeCompare(b.name));
|
|
@@ -2747,7 +2768,7 @@ async function listSnapshots(scope, p = paths()) {
|
|
|
2747
2768
|
try {
|
|
2748
2769
|
out.push(toSnapshot(await readSnapshotMeta(ref, p)));
|
|
2749
2770
|
} catch (err) {
|
|
2750
|
-
|
|
2771
|
+
log.warn(`skipping snapshots/${refKey(ref)}: ${err.message}`);
|
|
2751
2772
|
}
|
|
2752
2773
|
}
|
|
2753
2774
|
return out;
|
|
@@ -3026,15 +3047,15 @@ async function standingLinks(meta, p) {
|
|
|
3026
3047
|
async function openPorts(meta, cfg, p) {
|
|
3027
3048
|
for (const proxy of boxProxies(meta)) await openProxy(proxy, cfg);
|
|
3028
3049
|
for (const link3 of await standingLinks(meta, p)) {
|
|
3029
|
-
await openLink(link3, cfg).catch((err) =>
|
|
3050
|
+
await openLink(link3, cfg).catch((err) => log.warn(`could not open the link from ${link3.fromIp}: ${err.message}`));
|
|
3030
3051
|
}
|
|
3031
3052
|
}
|
|
3032
3053
|
async function closePorts(meta, cfg) {
|
|
3033
3054
|
for (const proxy of boxProxies(meta)) {
|
|
3034
|
-
await closeProxy(proxy, cfg).catch((err) =>
|
|
3055
|
+
await closeProxy(proxy, cfg).catch((err) => log.warn(`could not close port ${proxy.hostPort}: ${err.message}`));
|
|
3035
3056
|
}
|
|
3036
3057
|
for (const link3 of boxLinks(meta)) {
|
|
3037
|
-
await closeLink(link3, cfg).catch((err) =>
|
|
3058
|
+
await closeLink(link3, cfg).catch((err) => log.warn(`could not close the link from ${link3.fromIp}: ${err.message}`));
|
|
3038
3059
|
}
|
|
3039
3060
|
}
|
|
3040
3061
|
var reservedPorts = /* @__PURE__ */ new Set();
|
|
@@ -3076,7 +3097,7 @@ function recordState(meta, state, by, p, at = (/* @__PURE__ */ new Date()).toISO
|
|
|
3076
3097
|
try {
|
|
3077
3098
|
insertUsageEvent({ boxId: meta.id, owner: meta.owner, name: meta.name, at, state, by, vcpu: meta.vcpu, memMib: meta.memMib, diskGib: diskGibOf(meta, p) }, p);
|
|
3078
3099
|
} catch (err) {
|
|
3079
|
-
|
|
3100
|
+
log.warn(`usage ledger: ${err.message}`);
|
|
3080
3101
|
}
|
|
3081
3102
|
}
|
|
3082
3103
|
function isHibernated(meta, p) {
|
|
@@ -3095,7 +3116,7 @@ function toMachine(meta, p = paths()) {
|
|
|
3095
3116
|
try {
|
|
3096
3117
|
closeOpenRun(meta.id, (/* @__PURE__ */ new Date()).toISOString(), p);
|
|
3097
3118
|
} catch (err) {
|
|
3098
|
-
|
|
3119
|
+
log.warn(`usage ledger: ${err.message}`);
|
|
3099
3120
|
}
|
|
3100
3121
|
}
|
|
3101
3122
|
return {
|
|
@@ -3135,7 +3156,7 @@ async function readAllMeta(p) {
|
|
|
3135
3156
|
try {
|
|
3136
3157
|
metas.push(await readMachineMeta(ref, p));
|
|
3137
3158
|
} catch (err) {
|
|
3138
|
-
|
|
3159
|
+
log.warn(`skipping machines/${refKey(ref)}: ${err.message}`);
|
|
3139
3160
|
}
|
|
3140
3161
|
}
|
|
3141
3162
|
return metas;
|
|
@@ -3554,7 +3575,7 @@ async function pushAuthorizedKeys(box, vsock, p) {
|
|
|
3554
3575
|
return void 0;
|
|
3555
3576
|
} catch (err) {
|
|
3556
3577
|
const why = isUnknownOp(err) ? `its image predates base v0.6.0, whose kvbox-agent can replace authorized_keys (kvbox vm update ${shown(box)} moves it onto the current base)` : err.message;
|
|
3557
|
-
|
|
3578
|
+
log.warn(`box ${shown(box)} keeps the authorized_keys it was frozen with: ${why}`);
|
|
3558
3579
|
return why;
|
|
3559
3580
|
}
|
|
3560
3581
|
}
|
|
@@ -3563,7 +3584,7 @@ async function dropGuestVolumes(box, vsock) {
|
|
|
3563
3584
|
await dropVolumes(vsock, AGENT_REPLY_MS);
|
|
3564
3585
|
} catch (err) {
|
|
3565
3586
|
const why = isUnknownOp(err) ? `its image predates base v0.9.0, whose kvbox-agent can unmount them (kvbox vm update ${shown(box)} moves it onto the current base)` : err.message;
|
|
3566
|
-
|
|
3587
|
+
log.warn(`box ${shown(box)} keeps the volume mounts it was frozen with, over empty disks now: ${why}`);
|
|
3567
3588
|
}
|
|
3568
3589
|
}
|
|
3569
3590
|
async function pushEnv(box, vsock, p) {
|
|
@@ -3578,10 +3599,10 @@ async function pushEnv(box, vsock, p) {
|
|
|
3578
3599
|
function warnEnv(box, vars, err) {
|
|
3579
3600
|
if (isUnknownOp(err)) {
|
|
3580
3601
|
if (vars.length === 0) return;
|
|
3581
|
-
|
|
3602
|
+
log.warn(`box ${shown(box)} did not get its environment variables: its image predates base v0.10.0, whose kvbox-agent takes them (kvbox vm update ${shown(box)} moves it onto the current base)`);
|
|
3582
3603
|
return;
|
|
3583
3604
|
}
|
|
3584
|
-
|
|
3605
|
+
log.warn(`box ${shown(box)} did not get its environment variables: ${err.message}`);
|
|
3585
3606
|
}
|
|
3586
3607
|
var ENV_BOOT_WAIT_MS = 12e4;
|
|
3587
3608
|
function pushEnvAfterBoot(box, pid, vsock, p, timing = { replyMs: AGENT_REPLY_MS, waitMs: ENV_BOOT_WAIT_MS }) {
|
|
@@ -3649,7 +3670,7 @@ var stopMachine = locked(async function stopMachine2(ref, p = paths()) {
|
|
|
3649
3670
|
const m = p.machine(ref.owner, ref.name);
|
|
3650
3671
|
if (!vmAlive(meta) && !isHibernated(meta, p)) throw new KvboxError(`box ${shown(ref)} is already stopped`);
|
|
3651
3672
|
await shutdown(meta, cfg, p, 1e4);
|
|
3652
|
-
await compactDisk(m.overlay).catch((err) =>
|
|
3673
|
+
await compactDisk(m.overlay).catch((err) => log.warn(`box ${shown(ref)}: disk not compacted: ${err.message}`));
|
|
3653
3674
|
await rm3(m.hibernateDir, { recursive: true, force: true });
|
|
3654
3675
|
await rm3(m.memBase, { force: true });
|
|
3655
3676
|
const stopped = { ...meta, pid: null, memSnapshots: void 0, paused: void 0 };
|
|
@@ -4083,12 +4104,12 @@ async function dropLinksFrom(gone, p) {
|
|
|
4083
4104
|
for (const l of meta.links.filter(isGone)) {
|
|
4084
4105
|
await closeLink({ box: meta.id, fromIp: l.ip, toIp: meta.ip, port: l.port }, cfg).catch((err) => {
|
|
4085
4106
|
stuck.add(l);
|
|
4086
|
-
|
|
4107
|
+
log.warn(`could not close the link from removed box ${gone.name} into ${meta.name}: ${err.message}`);
|
|
4087
4108
|
});
|
|
4088
4109
|
}
|
|
4089
4110
|
const kept = meta.links.filter((l) => !isGone(l) || stuck.has(l)).map((l) => stuck.has(l) ? { ...l, stale: true } : l);
|
|
4090
4111
|
await writeMachineMeta({ ...meta, links: kept.length > 0 ? kept : void 0 }, p);
|
|
4091
|
-
}).catch((err) =>
|
|
4112
|
+
}).catch((err) => log.warn(`links of removed box ${gone.name}: ${err.message}`));
|
|
4092
4113
|
}
|
|
4093
4114
|
}
|
|
4094
4115
|
var RECOVERY_CONCURRENCY = 2;
|
|
@@ -4102,7 +4123,7 @@ async function settleDeadBoxes(p = paths()) {
|
|
|
4102
4123
|
try {
|
|
4103
4124
|
closeRunCutByBoot(meta.id, bootAt, now, p);
|
|
4104
4125
|
} catch (err) {
|
|
4105
|
-
|
|
4126
|
+
log.warn(`usage ledger: ${err.message}`);
|
|
4106
4127
|
}
|
|
4107
4128
|
await rm3(p.machine(meta.owner, meta.name).memBase, { force: true });
|
|
4108
4129
|
if (meta.paused) {
|
|
@@ -4123,7 +4144,7 @@ async function pinRunningTaps(p = paths()) {
|
|
|
4123
4144
|
if (!bridgeExists(cfg.bridge)) return;
|
|
4124
4145
|
for (const meta of await readAllMeta(p)) {
|
|
4125
4146
|
if (!vmAlive(meta) || !existsSync6(`/sys/class/net/${tapName(meta.id)}`)) continue;
|
|
4126
|
-
await pinTap(meta, cfg).catch((err) =>
|
|
4147
|
+
await pinTap(meta, cfg).catch((err) => log.warn(`could not pin box ${meta.name}'s tap: ${err.message}`));
|
|
4127
4148
|
}
|
|
4128
4149
|
}
|
|
4129
4150
|
var recovery = null;
|
|
@@ -4647,7 +4668,7 @@ function startIdleWatch(opts = {}) {
|
|
|
4647
4668
|
const hibernate = opts.hibernate ?? ((box) => hibernateIfRunning(box, p));
|
|
4648
4669
|
const busy = opts.busy ?? ((box) => boxBusy(box) || restoreRunning(box));
|
|
4649
4670
|
const now = opts.now ?? Date.now;
|
|
4650
|
-
const
|
|
4671
|
+
const log2 = opts.log ?? ((line) => log.info(line));
|
|
4651
4672
|
const seen = /* @__PURE__ */ new Map();
|
|
4652
4673
|
const checkErrors = /* @__PURE__ */ new Map();
|
|
4653
4674
|
let timer;
|
|
@@ -4657,10 +4678,10 @@ function startIdleWatch(opts = {}) {
|
|
|
4657
4678
|
inflight.add(box.id);
|
|
4658
4679
|
const byImage = bytes < 0;
|
|
4659
4680
|
try {
|
|
4660
|
-
if (await hibernate(box))
|
|
4681
|
+
if (await hibernate(box)) log2(`box ${box.owner}/${box.name}: ${byImage ? "idle by its own check" : "no network traffic"} for ${quiet} min; hibernated it (kvbox connect wakes it)`);
|
|
4661
4682
|
seen.delete(box.id);
|
|
4662
4683
|
} catch (err) {
|
|
4663
|
-
|
|
4684
|
+
log2(`warning: box ${box.owner}/${box.name}: could not hibernate it after ${quiet} min ${byImage ? "idle" : "without traffic"}: ${err.message}`);
|
|
4664
4685
|
seen.set(box.id, { bytes, since: t });
|
|
4665
4686
|
} finally {
|
|
4666
4687
|
inflight.delete(box.id);
|
|
@@ -4669,7 +4690,7 @@ function startIdleWatch(opts = {}) {
|
|
|
4669
4690
|
const askIdle = (box) => guestIdle(box).then(
|
|
4670
4691
|
(v) => (checkErrors.delete(box.id), v),
|
|
4671
4692
|
(err) => {
|
|
4672
|
-
if (checkErrors.get(box.id) !== err.message)
|
|
4693
|
+
if (checkErrors.get(box.id) !== err.message) log2(`warning: box ${box.owner}/${box.name}: its idle check ${box.idleCheck ?? ""} failed, so it counts as busy and does not hibernate: ${err.message}`);
|
|
4673
4694
|
checkErrors.set(box.id, err.message);
|
|
4674
4695
|
return false;
|
|
4675
4696
|
}
|
|
@@ -4708,7 +4729,7 @@ function startIdleWatch(opts = {}) {
|
|
|
4708
4729
|
};
|
|
4709
4730
|
const schedule = () => {
|
|
4710
4731
|
if (stopped) return;
|
|
4711
|
-
timer = setTimeout(() => void check().catch((err) =>
|
|
4732
|
+
timer = setTimeout(() => void check().catch((err) => log2(`warning: idle watch: ${err.message}`)).finally(schedule), intervalMs);
|
|
4712
4733
|
timer.unref();
|
|
4713
4734
|
};
|
|
4714
4735
|
schedule();
|
|
@@ -4739,7 +4760,7 @@ function startRelayWatch(opts = {}) {
|
|
|
4739
4760
|
const misses = opts.misses ?? 3;
|
|
4740
4761
|
const probe = opts.probe ?? pingRelay;
|
|
4741
4762
|
const p = opts.p ?? paths();
|
|
4742
|
-
const
|
|
4763
|
+
const log2 = opts.log ?? ((line) => log.info(line));
|
|
4743
4764
|
const restart = opts.restart ?? (async () => netSetup(await loadConfig(p), ["relay", "restart"]));
|
|
4744
4765
|
report = { restarts: 0, lastRestartAt: null };
|
|
4745
4766
|
let missed = 0;
|
|
@@ -4753,25 +4774,25 @@ function startRelayWatch(opts = {}) {
|
|
|
4753
4774
|
return;
|
|
4754
4775
|
}
|
|
4755
4776
|
if (await probe()) {
|
|
4756
|
-
if (stuck)
|
|
4777
|
+
if (stuck) log2(`relay ${cfg.relay.name}: the tunnel carries traffic again`);
|
|
4757
4778
|
missed = 0;
|
|
4758
4779
|
stuck = false;
|
|
4759
4780
|
return;
|
|
4760
4781
|
}
|
|
4761
4782
|
if (++missed < misses) return;
|
|
4762
4783
|
missed = 0;
|
|
4763
|
-
if (!stuck)
|
|
4784
|
+
if (!stuck) log2(`relay ${cfg.relay.name}: no answer through the tunnel for ${misses * intervalMs / 1e3} s; restarting it`);
|
|
4764
4785
|
try {
|
|
4765
4786
|
await restart();
|
|
4766
4787
|
report = { restarts: report.restarts + 1, lastRestartAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
4767
4788
|
} catch (err) {
|
|
4768
|
-
if (!stuck)
|
|
4789
|
+
if (!stuck) log.warn(`relay ${cfg.relay.name}: could not restart the tunnel: ${err.message}`);
|
|
4769
4790
|
}
|
|
4770
4791
|
stuck = true;
|
|
4771
4792
|
};
|
|
4772
4793
|
const schedule = () => {
|
|
4773
4794
|
if (stopped) return;
|
|
4774
|
-
timer = setTimeout(() => void round2().catch((err) =>
|
|
4795
|
+
timer = setTimeout(() => void round2().catch((err) => log.warn(`relay watch: ${err.message}`)).finally(schedule), intervalMs);
|
|
4775
4796
|
timer.unref();
|
|
4776
4797
|
};
|
|
4777
4798
|
schedule();
|
|
@@ -4802,7 +4823,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
4802
4823
|
}
|
|
4803
4824
|
|
|
4804
4825
|
// src/version.ts
|
|
4805
|
-
var VERSION = versionOf(import.meta.url, true ? "0.5.
|
|
4826
|
+
var VERSION = versionOf(import.meta.url, true ? "0.5.43" : void 0);
|
|
4806
4827
|
|
|
4807
4828
|
// src/caller.ts
|
|
4808
4829
|
import { createHash as createHash2, timingSafeEqual } from "node:crypto";
|
|
@@ -5437,7 +5458,7 @@ function createApp(opts = {}) {
|
|
|
5437
5458
|
if (err instanceof KvboxError) {
|
|
5438
5459
|
return c.json({ error: err.message }, err.exitCode === 2 ? 501 : 400);
|
|
5439
5460
|
}
|
|
5440
|
-
|
|
5461
|
+
log.error(`${c.req.method} ${c.req.path}: ${err.stack ?? err.message}`);
|
|
5441
5462
|
return c.json({ error: err.message }, 500);
|
|
5442
5463
|
});
|
|
5443
5464
|
return app;
|
|
@@ -5507,38 +5528,40 @@ async function listen(opts = {}) {
|
|
|
5507
5528
|
}
|
|
5508
5529
|
|
|
5509
5530
|
// src/index.ts
|
|
5531
|
+
var daemon = false;
|
|
5510
5532
|
var program = new Command("kvbox-server").description("kvbox host daemon: owns Firecracker and ~/.kvbox, serves the kvbox API").version(VERSION, "-v, --version").showHelpAfterError();
|
|
5511
5533
|
program.command("start", { isDefault: true }).description("serve the API on the local Unix socket (foreground)").option("--socket <path>", "socket to listen on (default: $KVBOX_HOME/server.sock)").action(async (opts) => {
|
|
5534
|
+
daemon = true;
|
|
5512
5535
|
await requireKvm();
|
|
5513
5536
|
const settled = await settleDeadBoxes(paths());
|
|
5514
|
-
await clearStagedBackups(paths()).catch((err) =>
|
|
5537
|
+
await clearStagedBackups(paths()).catch((err) => log.warn(`staged backups not cleared: ${err.message}`));
|
|
5515
5538
|
const { socketPath, https } = await listen(opts.socket ? { socketPath: opts.socket } : {});
|
|
5516
|
-
|
|
5539
|
+
log.info(`kvbox-server ${VERSION} listening on ${socketPath} (pid ${process.pid})`);
|
|
5517
5540
|
if (https) {
|
|
5518
5541
|
const cfg = await loadConfig(paths());
|
|
5519
|
-
|
|
5542
|
+
log.info(`control plane ${cfg.controlPlane?.name}: answering on ${https.url}`);
|
|
5520
5543
|
}
|
|
5521
5544
|
try {
|
|
5522
5545
|
const cfg = await loadConfig(paths());
|
|
5523
5546
|
const state = await ensureHostNetwork(cfg);
|
|
5524
|
-
|
|
5547
|
+
log.info(`host network: bridge ${cfg.bridge} ${state}`);
|
|
5525
5548
|
await pinRunningTaps(paths());
|
|
5526
5549
|
} catch (err) {
|
|
5527
|
-
|
|
5550
|
+
log.warn(`host network not ready (${err.message}); run: kvbox-server net up`);
|
|
5528
5551
|
}
|
|
5529
5552
|
try {
|
|
5530
5553
|
const relay = await restoreRelay(paths());
|
|
5531
|
-
if (relay)
|
|
5554
|
+
if (relay) log.info(`relay ${relay.name}: the control plane may reach this host through the tunnel again`);
|
|
5532
5555
|
} catch (err) {
|
|
5533
|
-
|
|
5556
|
+
log.warn(`the control plane may not reach this host through its relay (${err.message}); run: kvbox server relay <join string>`);
|
|
5534
5557
|
}
|
|
5535
5558
|
let dnsWarned = false;
|
|
5536
5559
|
const bindDns = () => {
|
|
5537
5560
|
loadConfig(paths()).then(async (cfg) => {
|
|
5538
5561
|
await startDns({ host: cfg.gateway });
|
|
5539
|
-
|
|
5562
|
+
log.info(`box names: <name>.kvbox answered on ${cfg.gateway}`);
|
|
5540
5563
|
}).catch((err) => {
|
|
5541
|
-
if (!dnsWarned)
|
|
5564
|
+
if (!dnsWarned) log.warn(`box names (<name>.kvbox) do not resolve yet (${err.message}); retrying`);
|
|
5542
5565
|
dnsWarned = true;
|
|
5543
5566
|
setTimeout(bindDns, DNS_RETRY_MS).unref();
|
|
5544
5567
|
});
|
|
@@ -5548,9 +5571,9 @@ program.command("start", { isDefault: true }).description("serve the API on the
|
|
|
5548
5571
|
startIdleWatch();
|
|
5549
5572
|
const recovery2 = await bootRecovered(settled, paths());
|
|
5550
5573
|
if (recovery2) {
|
|
5551
|
-
for (const box of recovery2.booted)
|
|
5552
|
-
for (const box of recovery2.leftStopped)
|
|
5553
|
-
for (const f of recovery2.failed)
|
|
5574
|
+
for (const box of recovery2.booted) log.info(`box ${box} was running when it went down; booted it again`);
|
|
5575
|
+
for (const box of recovery2.leftStopped) log.info(`box ${box} was in standby when it went down; its memory is gone, left stopped`);
|
|
5576
|
+
for (const f of recovery2.failed) log.warn(`box ${f.box} was running when it went down and did not come back: ${f.error}`);
|
|
5554
5577
|
}
|
|
5555
5578
|
});
|
|
5556
5579
|
program.command("join <control-plane-url>").description("register this host with a control plane (needs a one-time token minted there); it answers the control plane from its next start").requiredOption("--token <token>", "one-time join token from the control plane").option("--advertise <host-or-ip>", "address the control plane reaches this host at (default: this host's default-route address)").option("--name <name>", "how the control plane lists this host (default: hostname)").option("--country <country>", "where this host is, a name or a code (romania, US); kvbox new --country places boxes by it").action(async (url, opts) => {
|
|
@@ -5587,9 +5610,14 @@ try {
|
|
|
5587
5610
|
await program.parseAsync(process.argv);
|
|
5588
5611
|
} catch (err) {
|
|
5589
5612
|
if (err instanceof KvboxError) {
|
|
5590
|
-
|
|
5613
|
+
if (daemon) log.error(err.message);
|
|
5614
|
+
else console.error(`error: ${err.message}`);
|
|
5591
5615
|
process.exit(err.exitCode);
|
|
5592
5616
|
}
|
|
5617
|
+
if (daemon) {
|
|
5618
|
+
log.error(err.stack ?? String(err));
|
|
5619
|
+
process.exit(1);
|
|
5620
|
+
}
|
|
5593
5621
|
throw err;
|
|
5594
5622
|
}
|
|
5595
5623
|
//# sourceMappingURL=kvbox-server.js.map
|