home-hosted 0.9.10 → 0.9.11
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/AGENTS.md +35 -0
- package/dist/cli.js +118 -45
- package/dist/cli.js.map +1 -1
- package/docs/SERVERS.md +13 -0
- package/package.json +1 -1
- package/uis/stock/dist/assets/{index-B9Eov7QO.js → index-CB6K3K2b.js} +12 -12
- package/uis/stock/dist/index.html +1 -1
- package/uis/stock/dist/ui.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -131,6 +131,26 @@ workspace config guard, so a busy default port turns config tests red for the wr
|
|
|
131
131
|
the card beside it prints that sentence in full. Read both in **one** helper
|
|
132
132
|
(`failureMessage`, `src/shared/api-client.ts`) and scan for the hand-rolled fallback — a unit test
|
|
133
133
|
cannot see a call site that has not been written yet.
|
|
134
|
+
- **A state and the streak behind it are written together.** `health`, `healthFailures` and
|
|
135
|
+
`unhealthySince` describe one process's run, so a path that resets one and leaves the others
|
|
136
|
+
reports a duration that keeps counting while nothing is measured — measured as `status=crashed
|
|
137
|
+
health=unknown` beside `Unhealthy for 3m 17s` and a `Not Probed` row, on the card and the page.
|
|
138
|
+
The explicit stop had that shape and was fixed alone once; the exit paths behind it were the same
|
|
139
|
+
defect. One helper decides the trio (`setHealth`/`resetHealth` in `src/services/supervisor.ts`)
|
|
140
|
+
and a scan fails a direct assignment. **A client cannot assume the server got there** — a newer
|
|
141
|
+
UI is served against an older panel, so a UI rendering a *duration* gates it on the verdict it
|
|
142
|
+
prints beside it, not on whether the timestamp is present.
|
|
143
|
+
- **A measurement belongs to the process that produced it, and goes when that process does.**
|
|
144
|
+
`pid`, `responseMs` and `resources` are one run's numbers; a path that detaches the pid and keeps
|
|
145
|
+
them reports a stopped entry with a live CPU, RSS and probe (`Probe 2 Ms / RSS 64.2 MB / Procs 1`
|
|
146
|
+
beside `Stopped`, and `hh_server_cpu_percent` in the scrape). The two **exit** paths cleared them
|
|
147
|
+
and the explicit stop did not — and an **adopted** successor has no exit event at all, because the
|
|
148
|
+
panel is not its parent, so one helper (`endProcessReadings`) owns all four and a scan fails a
|
|
149
|
+
clear outside it. The rule is general: ask which **lifecycle** clears a field, not which function
|
|
150
|
+
happened to. `portState` is the deliberate exception — a port's occupancy outlives its process.
|
|
151
|
+
The client half is the same predicate as the paragraph above: both UIs read a reading through
|
|
152
|
+
`liveReadings` (`src/shared/server-readings.ts`), never off the frame, and never `?? 0` (a zero
|
|
153
|
+
is the value that looks like a measured idle process).
|
|
134
154
|
- **A list card and its detail page answer the same question; fix both.** The card is a summary of a
|
|
135
155
|
page someone opens *precisely because the summary was not enough* — so a fact the card states and
|
|
136
156
|
the page omits is worse than either alone. A stopped entry's card learned to say "not running"
|
|
@@ -140,6 +160,14 @@ workspace config guard, so a busy default port turns config tests red for the wr
|
|
|
140
160
|
explanation on the way in. When you give a surface an empty state, a reason or a qualifier, grep
|
|
141
161
|
for the other surface that renders the same field and land it there too — and prefer a shared
|
|
142
162
|
component or a scan test over two call sites remembering in parallel.
|
|
163
|
+
- **A replaced list is sent only when *this form* changed it, and merged against what it was
|
|
164
|
+
filled with.** `destinations` and `routes` are lists a patch replaces, so a save writes the
|
|
165
|
+
sender's whole view — including entries it never saw. Deciding that against live state makes
|
|
166
|
+
another client's save look like this form's own edit: measured with two tabs on one workspace
|
|
167
|
+
settings page, a destination added in one tab was removed from `settings.json` by the other
|
|
168
|
+
saving an unrelated toggle. Keep the baseline the block was filled with and compare the draft to
|
|
169
|
+
*that* (`mergeReplacedList`); a list that was never filled must not travel, because `[]` on a
|
|
170
|
+
replaced list means "delete every entry".
|
|
143
171
|
- **A refused operation is a failure, never an empty success.** The backup service answers a *plan*
|
|
144
172
|
for every archive, including ones it cannot read: `plan.error` carries the refusal and `items` is
|
|
145
173
|
empty. A caller that reads only `items` reports "restored 0 items" with exit 0, which on a blank
|
|
@@ -192,6 +220,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
|
|
|
192
220
|
local command must not open an unauthenticated `/api` route.
|
|
193
221
|
- **A server id is only unique inside its workspace.** Anything keyed by id alone — SSE, log buffers,
|
|
194
222
|
series, route params — must key on `(workspaceId, serverId)`, or same-named servers mix frames.
|
|
223
|
+
**So must "what this panel owns."** A per-workspace service answering a panel-wide question — "is
|
|
224
|
+
this pid ours?" — asks its own workspace and silently gets the wrong answer for the others: a port
|
|
225
|
+
held by a sibling workspace's server read as a stranger, so `free-port` terminated it and `follow`
|
|
226
|
+
adopted it into the wrong workspace (two workspaces then claimed one pid). The panel is the only
|
|
227
|
+
thing that can see every workspace, so it injects the answer (`SupervisorOptions.siblingServers`)
|
|
228
|
+
and a lone supervisor has none. Such a refusal must also say **where** the holder lives: "stop that
|
|
229
|
+
server instead" is a dead end when that server is on a page this workspace cannot show.
|
|
195
230
|
- **A workspace is the ownership boundary.** Servers, secrets, logs and nanny state belong to exactly
|
|
196
231
|
one; only listener, auth, TLS, host vitals, backups, UI and `run.json` are panel-wide. Reach a
|
|
197
232
|
per-workspace service through `PanelService.requireWorkspace(id)`, never a module global.
|
package/dist/cli.js
CHANGED
|
@@ -14317,8 +14317,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14317
14317
|
entry.restarts = 0;
|
|
14318
14318
|
if (entry.actor !== "policy") entry.healthRestarts = 0;
|
|
14319
14319
|
if (entry.actor !== "policy") entry.pendingRestart = null;
|
|
14320
|
-
entry
|
|
14321
|
-
entry.unhealthySince = null;
|
|
14320
|
+
this.resetHealth(entry);
|
|
14322
14321
|
this.persistEntryState(entry);
|
|
14323
14322
|
}
|
|
14324
14323
|
try {
|
|
@@ -14329,7 +14328,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14329
14328
|
};
|
|
14330
14329
|
entry.lastError = null;
|
|
14331
14330
|
entry.status = "starting";
|
|
14332
|
-
|
|
14331
|
+
this.resetHealth(entry);
|
|
14333
14332
|
this.publishServer(entry);
|
|
14334
14333
|
if (entry.config.persistent && await this.resumePersistent(entry)) return { ok: true };
|
|
14335
14334
|
if (!entry.config.persistent) {
|
|
@@ -14451,7 +14450,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14451
14450
|
port,
|
|
14452
14451
|
error: `server "${id}" is busy — try again in a moment`
|
|
14453
14452
|
};
|
|
14454
|
-
const { ours, foreign } = await this.portHolders(port);
|
|
14453
|
+
const { ours, foreign, siblings } = await this.portHolders(port);
|
|
14455
14454
|
if ([...ours, ...foreign].length === 0) {
|
|
14456
14455
|
const docker = await findDockerPortHolder(port);
|
|
14457
14456
|
if (docker !== null) {
|
|
@@ -14491,15 +14490,12 @@ var init_supervisor = __esmMin((() => {
|
|
|
14491
14490
|
error: `nothing is listening on port ${port} any more`
|
|
14492
14491
|
};
|
|
14493
14492
|
}
|
|
14494
|
-
if (foreign.length === 0) {
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
skipped: ours
|
|
14501
|
-
};
|
|
14502
|
-
}
|
|
14493
|
+
if (foreign.length === 0) return {
|
|
14494
|
+
...empty,
|
|
14495
|
+
port,
|
|
14496
|
+
error: this.heldByOurs(port, ours, siblings),
|
|
14497
|
+
skipped: ours
|
|
14498
|
+
};
|
|
14503
14499
|
this.log(entry, "system", `freeing port ${port}: asking pid ${foreign.join(", ")} to stop`);
|
|
14504
14500
|
const { stopped, forced } = await terminatePids(foreign, { graceMs: entry.config.stop.graceMs });
|
|
14505
14501
|
if (forced.length > 0) this.log(entry, "system", `pid ${forced.join(", ")} ignored SIGTERM and was killed`);
|
|
@@ -14533,14 +14529,27 @@ var init_supervisor = __esmMin((() => {
|
|
|
14533
14529
|
* in an old banner from killing a recycled pid.
|
|
14534
14530
|
*/
|
|
14535
14531
|
async portHolders(port) {
|
|
14536
|
-
const supervised = await this.supervisedPids();
|
|
14532
|
+
const { pids: supervised, siblings } = await this.supervisedPids();
|
|
14537
14533
|
const holders = await listPortHolders(port);
|
|
14538
14534
|
return {
|
|
14539
14535
|
ours: holders.filter((pid) => supervised.has(pid)),
|
|
14540
|
-
foreign: holders.filter((pid) => !supervised.has(pid))
|
|
14536
|
+
foreign: holders.filter((pid) => !supervised.has(pid)),
|
|
14537
|
+
siblings
|
|
14541
14538
|
};
|
|
14542
14539
|
}
|
|
14543
14540
|
/**
|
|
14541
|
+
* The sentence a refused port prints: names the holder, and where it lives when that is another
|
|
14542
|
+
* workspace, because "stop that server instead" is not actionable from a page that cannot show it.
|
|
14543
|
+
*
|
|
14544
|
+
* A sibling whose pid is one we refused is matched by pid, the one fact both sides agree on — a
|
|
14545
|
+
* same-named entry in this workspace would have been a different pid.
|
|
14546
|
+
*/
|
|
14547
|
+
heldByOurs(port, ours, siblings) {
|
|
14548
|
+
const owners = siblings.filter((sibling) => ours.includes(sibling.pid));
|
|
14549
|
+
const place = owners.length === 0 ? "" : ` on ${[...new Set(owners.map((owner) => `${owner.workspaceId}/${owner.serverId}`))].join(", ")}`;
|
|
14550
|
+
return `port ${port} is held by pid ${ours.join(", ")}, which this panel supervises${place} — stop that server instead`;
|
|
14551
|
+
}
|
|
14552
|
+
/**
|
|
14544
14553
|
* Pids of the processes this panel owns, plus itself — the whole *tree* of every
|
|
14545
14554
|
* entry, not just the pid it recorded.
|
|
14546
14555
|
*
|
|
@@ -14557,9 +14566,14 @@ var init_supervisor = __esmMin((() => {
|
|
|
14557
14566
|
const roots = [];
|
|
14558
14567
|
for (const entry of this.entries.values()) if (entry.pid !== null) roots.push(entry.pid);
|
|
14559
14568
|
else if (entry.child?.pid !== void 0) roots.push(entry.child.pid);
|
|
14569
|
+
const siblings = [...await this.options.siblingServers?.() ?? []];
|
|
14570
|
+
roots.push(...siblings.map((sibling) => sibling.pid));
|
|
14560
14571
|
const pids = await processTreePids(roots);
|
|
14561
14572
|
pids.add(process.pid);
|
|
14562
|
-
return
|
|
14573
|
+
return {
|
|
14574
|
+
pids,
|
|
14575
|
+
siblings
|
|
14576
|
+
};
|
|
14563
14577
|
}
|
|
14564
14578
|
/** The port's own answer, with the same short recheck the preflight uses. */
|
|
14565
14579
|
async waitForPortRelease(entry, port) {
|
|
@@ -14668,7 +14682,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14668
14682
|
});
|
|
14669
14683
|
const { port, stop } = entry.config;
|
|
14670
14684
|
if (stop.killPortHolders && port !== null) {
|
|
14671
|
-
const leftover = await killPortHolders(port, await this.supervisedPids());
|
|
14685
|
+
const leftover = await killPortHolders(port, (await this.supervisedPids()).pids);
|
|
14672
14686
|
if (leftover.length > 0) this.log(entry, "system", `port ${port} was still held by pid ${leftover.join(", ")} — killed`);
|
|
14673
14687
|
}
|
|
14674
14688
|
const survivor = entry.config.persistent && entry.pid !== null && isProcessAlive(entry.pid) ? entry.pid : null;
|
|
@@ -14681,9 +14695,10 @@ var init_supervisor = __esmMin((() => {
|
|
|
14681
14695
|
}
|
|
14682
14696
|
entry.stopping = false;
|
|
14683
14697
|
entry.child = null;
|
|
14684
|
-
entry
|
|
14685
|
-
entry.adopted = false;
|
|
14698
|
+
this.endProcessReadings(entry);
|
|
14686
14699
|
entry.nannyExit = null;
|
|
14700
|
+
this.endHealthStreak(entry);
|
|
14701
|
+
if (survivor === null || !entry.config.health.enabled) this.resetHealth(entry);
|
|
14687
14702
|
if (entry.lastChild !== null && !isProcessAlive(entry.lastChild.pid)) {
|
|
14688
14703
|
entry.lastChild = null;
|
|
14689
14704
|
this.persistEntryState(entry);
|
|
@@ -14697,6 +14712,56 @@ var init_supervisor = __esmMin((() => {
|
|
|
14697
14712
|
error: entry.lastError
|
|
14698
14713
|
};
|
|
14699
14714
|
}
|
|
14715
|
+
/**
|
|
14716
|
+
* The health state, together with the streak that produced it.
|
|
14717
|
+
*
|
|
14718
|
+
* `healthFailures` and `unhealthySince` describe one **process's** run: the failures since it
|
|
14719
|
+
* began, and the moment that streak turned unhealthy. They move with `health` for one reason —
|
|
14720
|
+
* a caller that set one and forgot the other left a duration counting up while nothing was
|
|
14721
|
+
* measured. Measured on the built panel: an entry that crashed while unhealthy reported
|
|
14722
|
+
* `status=crashed health=unknown` beside `Unhealthy for 3m 17s` and a `Not Probed` row, the
|
|
14723
|
+
* identical shape an explicit stop had before round 13 fixed that one path. Anything other
|
|
14724
|
+
* than `unhealthy` therefore ends the streak.
|
|
14725
|
+
*/
|
|
14726
|
+
setHealth(entry, health) {
|
|
14727
|
+
entry.health = health;
|
|
14728
|
+
if (health !== "unhealthy") this.endHealthStreak(entry);
|
|
14729
|
+
}
|
|
14730
|
+
/**
|
|
14731
|
+
* Forgets the streak without deciding the verdict.
|
|
14732
|
+
*
|
|
14733
|
+
* A refused stop is the one place the two differ: the process survived, so its `conflict`
|
|
14734
|
+
* outcome stays, while the duration that described the run cannot keep counting from a probe
|
|
14735
|
+
* that is no longer taken.
|
|
14736
|
+
*/
|
|
14737
|
+
endHealthStreak(entry) {
|
|
14738
|
+
entry.healthFailures = 0;
|
|
14739
|
+
entry.unhealthySince = null;
|
|
14740
|
+
}
|
|
14741
|
+
/** The health of an entry nothing is probing: `disabled` with the probe off, else `unknown`. */
|
|
14742
|
+
resetHealth(entry) {
|
|
14743
|
+
this.setHealth(entry, entry.config.health.enabled ? "unknown" : "disabled");
|
|
14744
|
+
}
|
|
14745
|
+
/**
|
|
14746
|
+
* The measurements one process produced, dropped when that process is gone.
|
|
14747
|
+
*
|
|
14748
|
+
* `pid`, `responseMs` and `resources` describe *one* run: the probe's last latency and the
|
|
14749
|
+
* sampler's last reading are that process's numbers, and nothing measured them again just
|
|
14750
|
+
* because the pid left. Both exit paths cleared them; an adopted entry has no exit event of its
|
|
14751
|
+
* own, so a stopped successor kept a live-looking CPU, RSS and probe beside `Status Stopped /
|
|
14752
|
+
* Health Not Probed` — and the sampler never corrects them, because it only visits entries with
|
|
14753
|
+
* a pid. The same numbers reached `/api/metrics`, where a stopped server published a real
|
|
14754
|
+
* `hh_server_cpu_percent` and `hh_server_rss_bytes`.
|
|
14755
|
+
*
|
|
14756
|
+
* `adopted` goes with them: it says *this pid* is a successor we took over, and there is no pid
|
|
14757
|
+
* left to say it of.
|
|
14758
|
+
*/
|
|
14759
|
+
endProcessReadings(entry) {
|
|
14760
|
+
entry.pid = null;
|
|
14761
|
+
entry.adopted = false;
|
|
14762
|
+
entry.responseMs = null;
|
|
14763
|
+
entry.resources = null;
|
|
14764
|
+
}
|
|
14700
14765
|
createEntry(config) {
|
|
14701
14766
|
const persisted = readEntryState(entryStatePath(this.options.nannyDir, config.id));
|
|
14702
14767
|
const lastPid = persisted?.lastPid ?? null;
|
|
@@ -14831,7 +14896,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14831
14896
|
}
|
|
14832
14897
|
entry.portState = free ? "free" : "in-use";
|
|
14833
14898
|
if (free) return { kind: "free" };
|
|
14834
|
-
const { ours, foreign } = await this.portHolders(port);
|
|
14899
|
+
const { ours, foreign, siblings } = await this.portHolders(port);
|
|
14835
14900
|
const holders = [...ours, ...foreign];
|
|
14836
14901
|
const own = await this.ownPortHolder(entry, foreign);
|
|
14837
14902
|
const docker = holders.length === 0 ? await findDockerPortHolder(port) : null;
|
|
@@ -14839,7 +14904,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14839
14904
|
if (entry.config.onPortConflict === "kill") {
|
|
14840
14905
|
if (ours.length > 0) {
|
|
14841
14906
|
entry.status = "conflict";
|
|
14842
|
-
entry.lastError =
|
|
14907
|
+
entry.lastError = this.heldByOurs(port, ours, siblings);
|
|
14843
14908
|
this.log(entry, "system", `${entry.lastError} — not starting (onPortConflict: kill)`);
|
|
14844
14909
|
this.publishServer(entry);
|
|
14845
14910
|
return {
|
|
@@ -14874,9 +14939,10 @@ var init_supervisor = __esmMin((() => {
|
|
|
14874
14939
|
return await this.stopPortHolders(entry, [own], port, "replacing", freeOnAll);
|
|
14875
14940
|
}
|
|
14876
14941
|
const hint = own !== null ? ` — pid ${own} is a detached restart of this entry: set onPortConflict to "follow" to adopt it, "reclaim" to replace it with a supervised process, or "kill" to stop whatever holds the port` : docker === null ? "" : ` — it is published by a docker container, which \`kill\` stops through docker; \`block\` and \`warn\` leave it alone`;
|
|
14942
|
+
const blockedError = ours.length > 0 ? this.heldByOurs(port, ours, siblings) : `port ${port} is already in use${suffix}${hint}`;
|
|
14877
14943
|
if (entry.config.onPortConflict !== "warn") {
|
|
14878
14944
|
entry.status = "conflict";
|
|
14879
|
-
entry.lastError =
|
|
14945
|
+
entry.lastError = blockedError;
|
|
14880
14946
|
this.log(entry, "system", `${entry.lastError} — not starting (onPortConflict: ${entry.config.onPortConflict})`);
|
|
14881
14947
|
this.publishServer(entry);
|
|
14882
14948
|
return {
|
|
@@ -14884,7 +14950,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14884
14950
|
error: entry.lastError
|
|
14885
14951
|
};
|
|
14886
14952
|
}
|
|
14887
|
-
this.log(entry, "system", `warning:
|
|
14953
|
+
this.log(entry, "system", `warning: ${blockedError} — starting anyway`);
|
|
14888
14954
|
return { kind: "free" };
|
|
14889
14955
|
}
|
|
14890
14956
|
/**
|
|
@@ -14931,7 +14997,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
14931
14997
|
entry.pid = pid;
|
|
14932
14998
|
entry.child = null;
|
|
14933
14999
|
entry.status = "running";
|
|
14934
|
-
|
|
15000
|
+
this.resetHealth(entry);
|
|
14935
15001
|
entry.startedAt = Date.now();
|
|
14936
15002
|
entry.lastError = null;
|
|
14937
15003
|
if (entry.config.persistent) this.followPersistent(entry, true);
|
|
@@ -14994,12 +15060,9 @@ var init_supervisor = __esmMin((() => {
|
|
|
14994
15060
|
const ranForMs = entry.nannyExit?.runtimeMs ?? (entry.startedAt === null ? 0 : Date.now() - entry.startedAt);
|
|
14995
15061
|
const detail = entry.nannyExit === null ? "adopted process exited" : describeNannyExit(entry.nannyExit);
|
|
14996
15062
|
entry.nannyExit = null;
|
|
14997
|
-
entry.adopted = false;
|
|
14998
|
-
entry.pid = null;
|
|
14999
15063
|
this.forgetRecordedChild(entry, adoptedPid);
|
|
15000
|
-
entry
|
|
15001
|
-
entry
|
|
15002
|
-
entry.health = entry.config.health.enabled ? "unknown" : "disabled";
|
|
15064
|
+
this.endProcessReadings(entry);
|
|
15065
|
+
this.resetHealth(entry);
|
|
15003
15066
|
entry.exitCode = null;
|
|
15004
15067
|
entry.exitSignal = null;
|
|
15005
15068
|
if (!entry.removed) this.options.history.record(entry.config.id, {
|
|
@@ -15225,8 +15288,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15225
15288
|
entry.exitSignal = null;
|
|
15226
15289
|
entry.nannyExit = null;
|
|
15227
15290
|
entry.lastProbeAt = 0;
|
|
15228
|
-
entry
|
|
15229
|
-
entry.unhealthySince = null;
|
|
15291
|
+
this.resetHealth(entry);
|
|
15230
15292
|
this.publishServer(entry);
|
|
15231
15293
|
child.once("error", (error) => {
|
|
15232
15294
|
entry.lastError = describeSpawnError(error, entry.config.command, cwd);
|
|
@@ -15301,7 +15363,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15301
15363
|
entry.pid = state.nannyPid;
|
|
15302
15364
|
entry.startedAt = state.startedAt;
|
|
15303
15365
|
entry.status = "running";
|
|
15304
|
-
|
|
15366
|
+
this.resetHealth(entry);
|
|
15305
15367
|
entry.portState = entry.config.port === null ? "unknown" : "in-use";
|
|
15306
15368
|
entry.lastError = null;
|
|
15307
15369
|
entry.nannyExit = null;
|
|
@@ -15384,7 +15446,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15384
15446
|
if (port === null) {
|
|
15385
15447
|
if (entry.child !== child || entry.status !== "starting") return;
|
|
15386
15448
|
entry.status = "running";
|
|
15387
|
-
entry
|
|
15449
|
+
this.setHealth(entry, health.enabled ? "unknown" : "disabled");
|
|
15388
15450
|
this.log(entry, "system", "running (no port configured; readiness assumed on spawn)");
|
|
15389
15451
|
this.settleRestart(entry, "it spawned and is running");
|
|
15390
15452
|
this.publishServer(entry);
|
|
@@ -15395,7 +15457,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15395
15457
|
if (entry.child !== child || entry.status !== "starting" || this.disposed) return;
|
|
15396
15458
|
if (await this.portAccepts(entry, port, Math.min(health.timeoutMs, 1e3))) {
|
|
15397
15459
|
entry.portState = "in-use";
|
|
15398
|
-
entry
|
|
15460
|
+
this.setHealth(entry, !health.enabled ? "disabled" : health.mode === "http" ? "unknown" : "healthy");
|
|
15399
15461
|
entry.status = "running";
|
|
15400
15462
|
entry.lastProbeAt = 0;
|
|
15401
15463
|
this.log(entry, "system", `accepting connections on port ${port}`);
|
|
@@ -15407,7 +15469,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15407
15469
|
}
|
|
15408
15470
|
if (entry.child === child && entry.status === "starting") {
|
|
15409
15471
|
entry.status = "running";
|
|
15410
|
-
entry
|
|
15472
|
+
this.setHealth(entry, "unhealthy");
|
|
15411
15473
|
entry.unhealthySince = Date.now();
|
|
15412
15474
|
this.log(entry, "system", `no connection on port ${port} after ${health.startTimeoutMs}ms — supervising anyway`);
|
|
15413
15475
|
this.publishServer(entry);
|
|
@@ -15420,11 +15482,8 @@ var init_supervisor = __esmMin((() => {
|
|
|
15420
15482
|
const nannyExit = entry.nannyExit;
|
|
15421
15483
|
entry.nannyExit = null;
|
|
15422
15484
|
entry.child = null;
|
|
15423
|
-
entry
|
|
15424
|
-
entry
|
|
15425
|
-
entry.resources = null;
|
|
15426
|
-
entry.responseMs = null;
|
|
15427
|
-
entry.health = entry.config.health.enabled ? "unknown" : "disabled";
|
|
15485
|
+
this.endProcessReadings(entry);
|
|
15486
|
+
this.resetHealth(entry);
|
|
15428
15487
|
entry.exitCode = code;
|
|
15429
15488
|
entry.exitSignal = signal;
|
|
15430
15489
|
this.forgetRecordedChild(entry, child.pid ?? null);
|
|
@@ -15551,9 +15610,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15551
15610
|
this.notify(entry, "recovered", probe.detail);
|
|
15552
15611
|
}
|
|
15553
15612
|
this.settleRestart(entry, `${probe.detail} (${probe.ms}ms)`);
|
|
15554
|
-
entry
|
|
15555
|
-
entry.healthFailures = 0;
|
|
15556
|
-
entry.unhealthySince = null;
|
|
15613
|
+
this.setHealth(entry, "healthy");
|
|
15557
15614
|
const servedForMs = entry.startedAt === null ? 0 : Date.now() - entry.startedAt;
|
|
15558
15615
|
if (entry.healthRestarts > 0 && servedForMs >= entry.config.restart.resetAfterMs) {
|
|
15559
15616
|
entry.healthRestarts = 0;
|
|
@@ -15572,7 +15629,7 @@ var init_supervisor = __esmMin((() => {
|
|
|
15572
15629
|
});
|
|
15573
15630
|
this.notify(entry, "unhealthy", probe.detail);
|
|
15574
15631
|
}
|
|
15575
|
-
entry
|
|
15632
|
+
this.setHealth(entry, "unhealthy");
|
|
15576
15633
|
}
|
|
15577
15634
|
} finally {
|
|
15578
15635
|
entry.probing = false;
|
|
@@ -19024,6 +19081,21 @@ var init_panel = __esmMin((() => {
|
|
|
19024
19081
|
if (workspaceId !== void 0) return this.runtimes.get(workspaceId)?.supervisor.views() ?? [];
|
|
19025
19082
|
return this.workspaces().flatMap((runtime) => runtime.supervisor.views());
|
|
19026
19083
|
}
|
|
19084
|
+
/**
|
|
19085
|
+
* The running servers of every workspace *except* `except`, so one supervisor can recognize a
|
|
19086
|
+
* sibling workspace's process as one the panel owns rather than a stranger to signal — and can
|
|
19087
|
+
* name it when it refuses.
|
|
19088
|
+
*
|
|
19089
|
+
* Read from the live views rather than from nanny state: an adopted entry has no child record,
|
|
19090
|
+
* and a persistent one's pid is the nanny's, whose tree the supervisor walks itself.
|
|
19091
|
+
*/
|
|
19092
|
+
siblingServers(except) {
|
|
19093
|
+
return this.workspaces().filter((runtime) => runtime.id !== except).flatMap((runtime) => runtime.supervisor.views().filter((view) => view.pid !== null).map((view) => ({
|
|
19094
|
+
pid: view.pid,
|
|
19095
|
+
workspaceId: runtime.id,
|
|
19096
|
+
serverId: view.id
|
|
19097
|
+
})));
|
|
19098
|
+
}
|
|
19027
19099
|
getState() {
|
|
19028
19100
|
const proxy = this.options.proxy();
|
|
19029
19101
|
return {
|
|
@@ -19214,7 +19286,8 @@ var init_panel = __esmMin((() => {
|
|
|
19214
19286
|
logFiles,
|
|
19215
19287
|
notifications,
|
|
19216
19288
|
onStateChange: () => this.scheduleState(),
|
|
19217
|
-
nannyDir: workspaceStateDir(id)
|
|
19289
|
+
nannyDir: workspaceStateDir(id),
|
|
19290
|
+
siblingServers: async () => this.siblingServers(id)
|
|
19218
19291
|
});
|
|
19219
19292
|
const runtime = {
|
|
19220
19293
|
id,
|