home-hosted 0.11.0 → 0.13.0
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/README.md +319 -628
- package/dist/chunks/archive-DP-XQR8X.js +352 -0
- package/dist/chunks/archive-DP-XQR8X.js.map +1 -0
- package/dist/chunks/atomic-C1PfJpE7.js +26 -0
- package/dist/chunks/atomic-C1PfJpE7.js.map +1 -0
- package/dist/chunks/backup-CZcVca2a.js +822 -0
- package/dist/chunks/backup-CZcVca2a.js.map +1 -0
- package/dist/chunks/backups-CFRaWe_m.js +4691 -0
- package/dist/chunks/backups-CFRaWe_m.js.map +1 -0
- package/dist/chunks/config-text-DifCHhnz.js +50 -0
- package/dist/chunks/config-text-DifCHhnz.js.map +1 -0
- package/dist/chunks/contracts-CMBD1TF9.js +2230 -0
- package/dist/chunks/contracts-CMBD1TF9.js.map +1 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js +241 -0
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +1 -0
- package/dist/chunks/daemon-qKVECISl.js +247 -0
- package/dist/chunks/daemon-qKVECISl.js.map +1 -0
- package/dist/chunks/docker-Cy9Lyvda.js +437 -0
- package/dist/chunks/docker-Cy9Lyvda.js.map +1 -0
- package/dist/chunks/down-pKbGCW9d.js +383 -0
- package/dist/chunks/down-pKbGCW9d.js.map +1 -0
- package/dist/chunks/init-BZ7hK9Vf.js +276 -0
- package/dist/chunks/init-BZ7hK9Vf.js.map +1 -0
- package/dist/chunks/last-stop-C-BXz_XI.js +53 -0
- package/dist/chunks/last-stop-C-BXz_XI.js.map +1 -0
- package/dist/chunks/layout-DwTtmund.js +24 -0
- package/dist/chunks/layout-DwTtmund.js.map +1 -0
- package/dist/chunks/lazy-Ce5zEAq1.js +66 -0
- package/dist/chunks/lazy-Ce5zEAq1.js.map +1 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.js +414 -0
- package/dist/chunks/log-buffer-Dy9HHDMD.js.map +1 -0
- package/dist/chunks/logger-B5U4GD3j.js +13 -0
- package/dist/chunks/logger-B5U4GD3j.js.map +1 -0
- package/dist/chunks/logs---TI_bxM.js +267 -0
- package/dist/chunks/logs---TI_bxM.js.map +1 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js +155 -0
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +1 -0
- package/dist/chunks/nanny-B-Eu0sFW.js +132 -0
- package/dist/chunks/nanny-B-Eu0sFW.js.map +1 -0
- package/dist/chunks/nanny-BtWfy0QH.js +1167 -0
- package/dist/chunks/nanny-BtWfy0QH.js.map +1 -0
- package/dist/chunks/nanny-ChMtq1Zl.js +39 -0
- package/dist/chunks/nanny-ChMtq1Zl.js.map +1 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.js +105 -0
- package/dist/chunks/nanny-sweep-DErnlPY1.js.map +1 -0
- package/dist/chunks/nearest-6KgQEDUe.js +41 -0
- package/dist/chunks/nearest-6KgQEDUe.js.map +1 -0
- package/dist/chunks/parse-DhmG26fI.js +383 -0
- package/dist/chunks/parse-DhmG26fI.js.map +1 -0
- package/dist/chunks/paths-CGlGDrOU.js +206 -0
- package/dist/chunks/paths-CGlGDrOU.js.map +1 -0
- package/dist/chunks/port-B8WBTRMk.js +333 -0
- package/dist/chunks/port-B8WBTRMk.js.map +1 -0
- package/dist/chunks/restart-Des4DrAN.js +92 -0
- package/dist/chunks/restart-Des4DrAN.js.map +1 -0
- package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/chunks/schema-B240VXcV.js +103 -0
- package/dist/chunks/schema-B240VXcV.js.map +1 -0
- package/dist/chunks/secrets-BieELnZh.js +562 -0
- package/dist/chunks/secrets-BieELnZh.js.map +1 -0
- package/dist/chunks/server-Bge2r2qQ.js +169 -0
- package/dist/chunks/server-Bge2r2qQ.js.map +1 -0
- package/dist/chunks/server-ids-DRuNLVCV.js +32 -0
- package/dist/chunks/server-ids-DRuNLVCV.js.map +1 -0
- package/dist/chunks/set-password-D5vZqqSX.js +43 -0
- package/dist/chunks/set-password-D5vZqqSX.js.map +1 -0
- package/dist/chunks/set-token-obPiEJYk.js +78 -0
- package/dist/chunks/set-token-obPiEJYk.js.map +1 -0
- package/dist/chunks/settings-xu-XTfWg.js +423 -0
- package/dist/chunks/settings-xu-XTfWg.js.map +1 -0
- package/dist/chunks/setup-temp-CAN4_bA-.js +150 -0
- package/dist/chunks/setup-temp-CAN4_bA-.js.map +1 -0
- package/dist/chunks/shape-DnTKzjQ2.js +24 -0
- package/dist/chunks/shape-DnTKzjQ2.js.map +1 -0
- package/dist/chunks/src-BtWMFmzZ.js +12338 -0
- package/dist/chunks/src-BtWMFmzZ.js.map +1 -0
- package/dist/chunks/status-DT1EsA-B.js +123 -0
- package/dist/chunks/status-DT1EsA-B.js.map +1 -0
- package/dist/chunks/ui-D562aqw5.js +325 -0
- package/dist/chunks/ui-D562aqw5.js.map +1 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js +39 -0
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +1 -0
- package/dist/chunks/ui-release-DKzVvlLd.js +312 -0
- package/dist/chunks/ui-release-DKzVvlLd.js.map +1 -0
- package/dist/chunks/ui-revert-EkBBwRTt.js +27 -0
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +1 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js +150 -0
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +1 -0
- package/dist/chunks/ui-update-_xryLYxw.js +272 -0
- package/dist/chunks/ui-update-_xryLYxw.js.map +1 -0
- package/dist/chunks/up-Pdz-l6IH.js +210 -0
- package/dist/chunks/up-Pdz-l6IH.js.map +1 -0
- package/dist/chunks/usage-DFrCVXpT.js +111 -0
- package/dist/chunks/usage-DFrCVXpT.js.map +1 -0
- package/dist/chunks/workspaces-DYcfvKV_.js +229 -0
- package/dist/chunks/workspaces-DYcfvKV_.js.map +1 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js +322 -0
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +1 -0
- package/dist/cli.js +441 -25418
- package/dist/cli.js.map +1 -1
- package/dist/client.js +144 -0
- package/dist/client.js.map +1 -0
- package/dist/types/api/acme.d.ts +24 -0
- package/dist/types/api/auth/$.routes.d.ts +103 -0
- package/dist/types/api/backups.d.ts +184 -0
- package/dist/types/api/control.d.ts +470 -0
- package/dist/types/api/ddns.d.ts +432 -0
- package/dist/types/api/events.d.ts +22 -0
- package/dist/types/api/health.d.ts +28 -0
- package/dist/types/api/logs.d.ts +95 -0
- package/dist/types/api/metrics.d.ts +21 -0
- package/dist/types/api/notifications.d.ts +141 -0
- package/dist/types/api/proxy.d.ts +1128 -0
- package/dist/types/api/servers/$.routes.d.ts +1318 -0
- package/dist/types/api/settings.d.ts +642 -0
- package/dist/types/api/state.d.ts +498 -0
- package/dist/types/api/static.d.ts +11 -0
- package/dist/types/api/tls.d.ts +112 -0
- package/dist/types/api/workspaces/$.routes.d.ts +797 -0
- package/dist/types/api/wsl-temperature.d.ts +113 -0
- package/dist/types/app.d.ts +6095 -0
- package/dist/types/cli/args.d.ts +75 -0
- package/dist/types/cli/backup-offline.d.ts +23 -0
- package/dist/types/cli/backup.d.ts +86 -0
- package/dist/types/cli/down.d.ts +80 -0
- package/dist/types/cli/init.d.ts +60 -0
- package/dist/types/cli/io.d.ts +65 -0
- package/dist/types/cli/logs.d.ts +76 -0
- package/dist/types/cli/migrate.d.ts +33 -0
- package/dist/types/cli/nanny.d.ts +19 -0
- package/dist/types/cli/nearest.d.ts +10 -0
- package/dist/types/cli/restart.d.ts +41 -0
- package/dist/types/cli/server.d.ts +68 -0
- package/dist/types/cli/set-password.d.ts +14 -0
- package/dist/types/cli/set-token.d.ts +21 -0
- package/dist/types/cli/setup-temp.d.ts +65 -0
- package/dist/types/cli/status.d.ts +14 -0
- package/dist/types/cli/ui-revert.d.ts +3 -0
- package/dist/types/cli/ui-switch.d.ts +27 -0
- package/dist/types/cli/ui-update.d.ts +72 -0
- package/dist/types/cli/up.d.ts +96 -0
- package/dist/types/cli/usage.d.ts +23 -0
- package/dist/types/cli.d.ts +12 -0
- package/dist/types/client.d.ts +11891 -0
- package/dist/types/config/layout.d.ts +11 -0
- package/dist/types/config/migrations.d.ts +69 -0
- package/dist/types/config/parse.d.ts +54 -0
- package/dist/types/config/patch.d.ts +20 -0
- package/dist/types/config/schema.d.ts +318 -0
- package/dist/types/config/secret-parts.d.ts +48 -0
- package/dist/types/config/secrets.d.ts +208 -0
- package/dist/types/config/seed.d.ts +30 -0
- package/dist/types/config/server-ids.d.ts +14 -0
- package/dist/types/config/settings.d.ts +120 -0
- package/dist/types/config/store.d.ts +145 -0
- package/dist/types/config/workspaces.d.ts +99 -0
- package/dist/types/helpers/action-result.d.ts +46 -0
- package/dist/types/helpers/atomic.d.ts +9 -0
- package/dist/types/helpers/backoff.d.ts +7 -0
- package/dist/types/helpers/bind.d.ts +16 -0
- package/dist/types/helpers/config-text.d.ts +23 -0
- package/dist/types/helpers/cookies.d.ts +19 -0
- package/dist/types/helpers/copy-tree.d.ts +20 -0
- package/dist/types/helpers/daemon-log.d.ts +45 -0
- package/dist/types/helpers/daemon.d.ts +135 -0
- package/dist/types/helpers/deferred.d.ts +7 -0
- package/dist/types/helpers/env-file.d.ts +20 -0
- package/dist/types/helpers/error.d.ts +26 -0
- package/dist/types/helpers/event-stream.d.ts +21 -0
- package/dist/types/helpers/factory.d.ts +6 -0
- package/dist/types/helpers/last-stop.d.ts +20 -0
- package/dist/types/helpers/logger.d.ts +7 -0
- package/dist/types/helpers/open.d.ts +2 -0
- package/dist/types/helpers/openapi.d.ts +34 -0
- package/dist/types/helpers/paths.d.ts +112 -0
- package/dist/types/helpers/restore-lock.d.ts +32 -0
- package/dist/types/helpers/runtime.d.ts +18 -0
- package/dist/types/helpers/secret-compare.d.ts +13 -0
- package/dist/types/helpers/shell.d.ts +19 -0
- package/dist/types/helpers/sse.d.ts +23 -0
- package/dist/types/helpers/template.d.ts +8 -0
- package/dist/types/helpers/ui-dir.d.ts +11 -0
- package/dist/types/helpers/utf8-chunks.d.ts +15 -0
- package/dist/types/helpers/validate.d.ts +7 -0
- package/dist/types/helpers/validator.d.ts +12 -0
- package/dist/types/helpers/version.d.ts +10 -0
- package/dist/types/helpers/workspace.d.ts +25 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/middleware/auth.d.ts +53 -0
- package/dist/types/middleware/host.d.ts +29 -0
- package/dist/types/middleware/loopback.d.ts +18 -0
- package/dist/types/openapi-reference.d.ts +22 -0
- package/dist/types/openapi.d.ts +34 -0
- package/dist/types/providers/archive.d.ts +54 -0
- package/dist/types/providers/backup-hook.d.ts +34 -0
- package/dist/types/providers/ddns/cloudflare.d.ts +2 -0
- package/dist/types/providers/ddns/desec.d.ts +2 -0
- package/dist/types/providers/ddns/digitalocean.d.ts +2 -0
- package/dist/types/providers/ddns/duckdns.d.ts +2 -0
- package/dist/types/providers/ddns/dyndns2.d.ts +15 -0
- package/dist/types/providers/ddns/dynu.d.ts +2 -0
- package/dist/types/providers/ddns/freedns.d.ts +2 -0
- package/dist/types/providers/ddns/gandi.d.ts +2 -0
- package/dist/types/providers/ddns/godaddy.d.ts +2 -0
- package/dist/types/providers/ddns/henet.d.ts +3 -0
- package/dist/types/providers/ddns/index.d.ts +12 -0
- package/dist/types/providers/ddns/ip.d.ts +27 -0
- package/dist/types/providers/ddns/namecheap-api.d.ts +13 -0
- package/dist/types/providers/ddns/namecheap.d.ts +6 -0
- package/dist/types/providers/ddns/noip.d.ts +2 -0
- package/dist/types/providers/ddns/porkbun.d.ts +2 -0
- package/dist/types/providers/ddns/spaceship.d.ts +7 -0
- package/dist/types/providers/ddns/types.d.ts +98 -0
- package/dist/types/providers/ddns/zone.d.ts +11 -0
- package/dist/types/providers/docker.d.ts +117 -0
- package/dist/types/providers/entry-state.d.ts +15 -0
- package/dist/types/providers/health-check.d.ts +27 -0
- package/dist/types/providers/host.d.ts +147 -0
- package/dist/types/providers/identity.d.ts +54 -0
- package/dist/types/providers/log-tail.d.ts +56 -0
- package/dist/types/providers/nanny-sweep.d.ts +54 -0
- package/dist/types/providers/nanny.d.ts +104 -0
- package/dist/types/providers/port.d.ts +142 -0
- package/dist/types/providers/proc.d.ts +125 -0
- package/dist/types/providers/process.d.ts +78 -0
- package/dist/types/providers/proxy/caddy.d.ts +2 -0
- package/dist/types/providers/proxy/index.d.ts +7 -0
- package/dist/types/providers/proxy/types.d.ts +54 -0
- package/dist/types/providers/server-vars.d.ts +4 -0
- package/dist/types/providers/telegram.d.ts +74 -0
- package/dist/types/providers/ui-release.d.ts +113 -0
- package/dist/types/providers/webhook.d.ts +64 -0
- package/dist/types/providers/wsl-temperature.d.ts +65 -0
- package/dist/types/services/acme-challenge.d.ts +44 -0
- package/dist/types/services/auth.d.ts +177 -0
- package/dist/types/services/backups.d.ts +476 -0
- package/dist/types/services/config-watch.d.ts +40 -0
- package/dist/types/services/control-server.d.ts +58 -0
- package/dist/types/services/ddns.d.ts +72 -0
- package/dist/types/services/dependencies.d.ts +21 -0
- package/dist/types/services/events.d.ts +17 -0
- package/dist/types/services/exposure.d.ts +86 -0
- package/dist/types/services/history.d.ts +37 -0
- package/dist/types/services/host-monitor.d.ts +33 -0
- package/dist/types/services/init.d.ts +71 -0
- package/dist/types/services/log-buffer.d.ts +39 -0
- package/dist/types/services/log-files.d.ts +77 -0
- package/dist/types/services/log-relay.d.ts +35 -0
- package/dist/types/services/nanny.d.ts +14 -0
- package/dist/types/services/notifications.d.ts +124 -0
- package/dist/types/services/panel.d.ts +213 -0
- package/dist/types/services/proxy-certificates/certificates.d.ts +116 -0
- package/dist/types/services/proxy-config.d.ts +83 -0
- package/dist/types/services/proxy.d.ts +431 -0
- package/dist/types/services/state.d.ts +38 -0
- package/dist/types/services/supervisor/compose.d.ts +17 -0
- package/dist/types/services/supervisor/entry.d.ts +149 -0
- package/dist/types/services/supervisor/health.d.ts +56 -0
- package/dist/types/services/supervisor/output.d.ts +126 -0
- package/dist/types/services/supervisor/pending-load.d.ts +6 -0
- package/dist/types/services/supervisor/persistent.d.ts +58 -0
- package/dist/types/services/supervisor/port-preflight.d.ts +45 -0
- package/dist/types/services/supervisor/records.d.ts +118 -0
- package/dist/types/services/supervisor/spawn.d.ts +15 -0
- package/dist/types/services/supervisor/view.d.ts +4 -0
- package/dist/types/services/supervisor.d.ts +145 -0
- package/dist/types/services/tls.d.ts +48 -0
- package/dist/types/services/ui-update.d.ts +44 -0
- package/dist/types/services/ui.d.ts +50 -0
- package/dist/types/shared/action-outcome.d.ts +25 -0
- package/dist/types/shared/api-client.d.ts +351 -0
- package/dist/types/shared/backup-scope.d.ts +167 -0
- package/dist/types/shared/clone.d.ts +14 -0
- package/dist/types/shared/contracts.d.ts +4175 -0
- package/dist/types/shared/cpu-scale.d.ts +25 -0
- package/dist/types/shared/ddns-form.d.ts +75 -0
- package/dist/types/shared/endpoint.d.ts +8 -0
- package/dist/types/shared/error-message.d.ts +8 -0
- package/dist/types/shared/fields.d.ts +21 -0
- package/dist/types/shared/form-repair.d.ts +6 -0
- package/dist/types/shared/generated.d.ts +26 -0
- package/dist/types/shared/host-readings.d.ts +185 -0
- package/dist/types/shared/lazy.d.ts +4 -0
- package/dist/types/shared/live-frames.d.ts +22 -0
- package/dist/types/shared/live-series.d.ts +21 -0
- package/dist/types/shared/live-store.d.ts +72 -0
- package/dist/types/shared/patch-diff.d.ts +105 -0
- package/dist/types/shared/probe-latency.d.ts +25 -0
- package/dist/types/shared/proxy-form.d.ts +184 -0
- package/dist/types/shared/server-attention.d.ts +37 -0
- package/dist/types/shared/server-form.d.ts +121 -0
- package/dist/types/shared/server-key.d.ts +13 -0
- package/dist/types/shared/server-readings.d.ts +55 -0
- package/dist/types/shared/server-url.d.ts +43 -0
- package/dist/types/shared/shape.d.ts +17 -0
- package/dist/types/shared/stream-access.d.ts +20 -0
- package/dist/types/shared/ui-format.d.ts +89 -0
- package/docs/API.md +209 -0
- package/docs/BACKUPS.md +117 -0
- package/docs/CLI.md +95 -0
- package/docs/DDNS.md +11 -1
- package/docs/NOTIFICATIONS.md +7 -1
- package/docs/REVERSE_PROXY.md +9 -3
- package/docs/SECURITY.md +93 -0
- package/docs/SERVERS.md +141 -34
- package/docs/UI_CREATION.md +91 -291
- package/docs/demo/blank-host-restore.sh +4 -3
- package/package.json +22 -14
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +1 -0
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +1 -0
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +1 -0
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +39 -0
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +2 -0
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +2 -0
- package/uis/stock/dist/assets/de-BRITeb0H.js +1 -0
- package/uis/stock/dist/assets/es-B2zIEssV.js +1 -0
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +1 -0
- package/uis/stock/dist/assets/index-C1MehbKy.css +2 -0
- package/uis/stock/dist/assets/index-CnBN54wF.js +15 -0
- package/uis/stock/dist/assets/ja-CU7MR85V.js +1 -0
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +1 -0
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +1 -0
- package/uis/stock/dist/assets/vi-CzvY16k2.js +1 -0
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +1 -0
- package/uis/stock/dist/index.html +3 -2
- package/uis/stock/dist/ui.json +3 -3
- package/docs/RESTORE_DEMO.md +0 -306
- package/uis/stock/dist/assets/de-0YLueNal.js +0 -1
- package/uis/stock/dist/assets/es-FCHhRmn2.js +0 -1
- package/uis/stock/dist/assets/fr-C69Z8o0z.js +0 -1
- package/uis/stock/dist/assets/index-Cok5msAO.css +0 -2
- package/uis/stock/dist/assets/index-KdyqrVv8.js +0 -53
- package/uis/stock/dist/assets/ja-Chz9YOqR.js +0 -1
- package/uis/stock/dist/assets/ko-CtXZ2x1l.js +0 -1
- package/uis/stock/dist/assets/ru-D_jE64xN.js +0 -1
- package/uis/stock/dist/assets/vi-sxSffss7.js +0 -1
- package/uis/stock/dist/assets/zh-CN-ChTpf29X.js +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface HostParts {
|
|
2
|
+
/** The registered domain (the zone), e.g. `example.com`. */
|
|
3
|
+
zone: string;
|
|
4
|
+
/** The record name inside that zone; `@` for the apex. */
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Splits a hostname into the zone and the record name, which is what every
|
|
9
|
+
* provider that has no zone lookup needs. `zone` short-circuits the heuristic.
|
|
10
|
+
*/
|
|
11
|
+
export declare function splitHost(host: string, zone?: string): HostParts;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** One container docker reports, with the labels that attribute it to a project. */
|
|
2
|
+
export interface ContainerRow {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
project: string | null;
|
|
6
|
+
configFiles: string[];
|
|
7
|
+
}
|
|
8
|
+
/** What one compose entry's containers add up to. */
|
|
9
|
+
export interface ComposeReading {
|
|
10
|
+
/** Summed CPU share, so 200 is two saturated cores. */
|
|
11
|
+
cpuPercent: number;
|
|
12
|
+
rssBytes: number;
|
|
13
|
+
/** Processes inside the containers — the same question the tree sampler answers. */
|
|
14
|
+
processes: number;
|
|
15
|
+
/** How many containers the sum covers. */
|
|
16
|
+
containers: number;
|
|
17
|
+
}
|
|
18
|
+
/** The evidence that an entry runs a compose project, and the key its containers are attributed by. */
|
|
19
|
+
export interface ComposeTarget {
|
|
20
|
+
/** What the caller looks the reading up by: the project, else the compose files. */
|
|
21
|
+
key: string;
|
|
22
|
+
project: string | null;
|
|
23
|
+
configFiles: string[];
|
|
24
|
+
}
|
|
25
|
+
/** `816KiB` -> bytes. Docker prints binary units for memory, and `0B` for a container that is not running. */
|
|
26
|
+
export declare function parseHumanBytes(value: string): number | null;
|
|
27
|
+
/** `MemUsage` is `used / limit`; only the used part measures this stack. */
|
|
28
|
+
export declare function parseMemUsage(value: string): number | null;
|
|
29
|
+
/** `99.61%` -> 99.61. `--` is docker's "no reading", which must not become a zero. */
|
|
30
|
+
export declare function parsePercent(value: string): number | null;
|
|
31
|
+
/** The containers docker reports, from the tab-separated `--format` above. */
|
|
32
|
+
export declare function parseDockerPs(text: string): ContainerRow[];
|
|
33
|
+
/** Per-container readings from `docker stats --no-stream --format json`, keyed by container id. */
|
|
34
|
+
export declare function parseDockerStats(text: string): Map<string, Omit<ComposeReading, 'containers'>>;
|
|
35
|
+
/**
|
|
36
|
+
* The compose options before the subcommand, and where the subcommand starts.
|
|
37
|
+
*
|
|
38
|
+
* Compose requires its global options **before** the subcommand — it answers `unknown shorthand
|
|
39
|
+
* flag: 'p'` for `up -p x` — so only this leading run can carry the project name or the file.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseComposeHead(args: string[]): {
|
|
42
|
+
subcommandAt: number;
|
|
43
|
+
projectName: string | null;
|
|
44
|
+
files: string[];
|
|
45
|
+
projectDirectory: string | null;
|
|
46
|
+
};
|
|
47
|
+
/** The compose file compose would pick: the first known name here or in a parent directory. */
|
|
48
|
+
export declare function findComposeFile(from: string): string[];
|
|
49
|
+
/** Whether this argv runs a compose stack, without resolving anything — a cheap pre-check. */
|
|
50
|
+
export declare function isComposeCommand(command: string, args: string[]): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The compose project an entry runs, from evidence in its own config: the command it spawns, its
|
|
53
|
+
* argv, its cwd and its environment. `null` means "sample the process tree", which is the right
|
|
54
|
+
* answer for every entry this cannot attribute honestly — see the module comment for the limits.
|
|
55
|
+
*/
|
|
56
|
+
export declare function composeTarget(input: {
|
|
57
|
+
command: string;
|
|
58
|
+
args: string[];
|
|
59
|
+
cwd: string;
|
|
60
|
+
env?: Record<string, string | undefined>;
|
|
61
|
+
}): ComposeTarget | null;
|
|
62
|
+
/**
|
|
63
|
+
* The containers belonging to one target, or `null` when that cannot be decided.
|
|
64
|
+
*
|
|
65
|
+
* `null` is the ambiguity refusal: two projects sharing a compose file can only be told apart by an
|
|
66
|
+
* explicit project name, so picking one would report another stack's CPU and RSS as this entry's.
|
|
67
|
+
*/
|
|
68
|
+
export declare function attributeContainers(target: ComposeTarget, rows: ContainerRow[]): ContainerRow[] | null;
|
|
69
|
+
/**
|
|
70
|
+
* The sum over one project's containers.
|
|
71
|
+
*
|
|
72
|
+
* Exported so the arithmetic is testable against the shapes docker actually prints; the class below
|
|
73
|
+
* only decides when to spawn. `null` for no containers, and for a listed container without a
|
|
74
|
+
* reading — an under-report is the one direction a memory ceiling must not miss.
|
|
75
|
+
*/
|
|
76
|
+
export declare function sumContainers(rows: ContainerRow[], readings: Map<string, Omit<ComposeReading, 'containers'>>): ComposeReading | null;
|
|
77
|
+
/** Whether a container publishing a port belongs to the stack this entry itself declares. */
|
|
78
|
+
export declare function isOwnStack(holder: {
|
|
79
|
+
project: string | null;
|
|
80
|
+
composeDir: string | null;
|
|
81
|
+
}, target: ComposeTarget | null): boolean;
|
|
82
|
+
/** One target's running containers from a fresh `docker ps`, or `null` when docker cannot answer. */
|
|
83
|
+
export declare function composeContainers(target: ComposeTarget): Promise<ContainerRow[] | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Stops every container of one target and reports what is still running afterwards.
|
|
86
|
+
*
|
|
87
|
+
* The answer comes from a **fresh listing**, not from `docker stop`'s exit code: a stop that
|
|
88
|
+
* printed success for a container still listed is the empty success this exists to refuse.
|
|
89
|
+
* `null` means docker could not be asked, which is not the same as "it stopped".
|
|
90
|
+
*/
|
|
91
|
+
export declare function stopComposeContainers(target: ComposeTarget): Promise<{
|
|
92
|
+
stopped: string[];
|
|
93
|
+
survivors: string[];
|
|
94
|
+
} | null>;
|
|
95
|
+
/**
|
|
96
|
+
* Container readings per compose project, refreshed out of band.
|
|
97
|
+
*
|
|
98
|
+
* One `docker ps` and one batched `docker stats` serve every docker-backed entry, however many
|
|
99
|
+
* there are. When docker cannot be reached the cache is emptied rather than filled with zeros: the
|
|
100
|
+
* caller keeps the process-tree sample, which is at least true of the wrapper, and a metric with no
|
|
101
|
+
* reading is never published as an idle one.
|
|
102
|
+
*/
|
|
103
|
+
export declare class DockerMetrics {
|
|
104
|
+
private cache;
|
|
105
|
+
private refreshing;
|
|
106
|
+
/**
|
|
107
|
+
* The last completed readings, and a refresh started when they are stale.
|
|
108
|
+
*
|
|
109
|
+
* Deliberately synchronous: the spawn takes seconds, and awaiting it here would stretch the
|
|
110
|
+
* supervisor tick that publishes the whole state frame. A fresh reading lands on a later tick.
|
|
111
|
+
*/
|
|
112
|
+
readings(targets: ComposeTarget[], now?: number): ReadonlyMap<string, ComposeReading>;
|
|
113
|
+
/** Resolves once the refresh in flight, if any, has finished. */
|
|
114
|
+
settle(): Promise<void>;
|
|
115
|
+
/** One listing and one batched stats call; replaces the cache only with a complete answer. */
|
|
116
|
+
refresh(targets: ComposeTarget[], now?: number): Promise<void>;
|
|
117
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EntryState } from '../shared/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* The small slice of a server's runtime the panel has to remember across its own
|
|
4
|
+
* restarts: how much of the retry budget is spent, and whether a `runOnce` bootstrap
|
|
5
|
+
* already ran.
|
|
6
|
+
*
|
|
7
|
+
* Both lived only in memory, so a panel restart — a `restart`, a crash, a reboot —
|
|
8
|
+
* handed a crash-looping server a fresh `maxRetries` and re-ran its bootstrap. The
|
|
9
|
+
* retry counter has to outlive the process that increments it to bound anything.
|
|
10
|
+
*/
|
|
11
|
+
/** One JSON file per entry, beside the nanny's own state. */
|
|
12
|
+
export declare function entryStatePath(dir: string, id: string): string;
|
|
13
|
+
export declare function readEntryState(file: string): EntryState | null;
|
|
14
|
+
export declare function writeEntryState(file: string, state: EntryState): void;
|
|
15
|
+
export declare function clearEntryState(file: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpCheckConfig } from '../shared/contracts.js';
|
|
2
|
+
export interface HealthProbeResult {
|
|
3
|
+
healthy: boolean;
|
|
4
|
+
ms: number;
|
|
5
|
+
detail: string;
|
|
6
|
+
}
|
|
7
|
+
/** TCP connect timing, used for the default `port` mode and readiness. */
|
|
8
|
+
export declare function probeTcp(host: string, port: number, timeoutMs: number): Promise<HealthProbeResult>;
|
|
9
|
+
export interface HttpProbeOptions extends Pick<HttpCheckConfig, 'scheme' | 'allowInvalidCert' | 'path' | 'method' | 'expectBody' | 'expectStatusBelow'> {
|
|
10
|
+
/** `null` counts as "not set", so a value saved by the UI can be cleared again. */
|
|
11
|
+
expectStatus?: number | null;
|
|
12
|
+
timeoutMs: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Fetches the configured path and asserts the response, so "listening" is not
|
|
16
|
+
* mistaken for "working".
|
|
17
|
+
*/
|
|
18
|
+
export declare function probeHttp(host: string, port: number, options: HttpProbeOptions): Promise<HealthProbeResult>;
|
|
19
|
+
export declare function probeHealth(options: {
|
|
20
|
+
mode: 'port' | 'http';
|
|
21
|
+
hosts: string[];
|
|
22
|
+
port: number;
|
|
23
|
+
timeoutMs: number;
|
|
24
|
+
http: Pick<HttpCheckConfig, 'scheme' | 'allowInvalidCert' | 'path' | 'method' | 'expectBody' | 'expectStatusBelow'> & {
|
|
25
|
+
expectStatus?: number | null;
|
|
26
|
+
};
|
|
27
|
+
}): Promise<HealthProbeResult>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { HostConfig, HostView } from '../shared/contracts.js';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a cached reading may be reused.
|
|
5
|
+
*
|
|
6
|
+
* Separate from the reading itself so the rule can be tested anywhere — the read is
|
|
7
|
+
* `sysctl`/PowerShell, which no CI runner but macOS and Windows can perform, and a bug here
|
|
8
|
+
* would be one that only shows up as either a stale alert or a spawn storm.
|
|
9
|
+
*
|
|
10
|
+
* A stamp in the future (a backwards wall-clock step) counts as stale: with a plain
|
|
11
|
+
* `now - at < ttl` it computes a negative age, which is "fresh", and the reading would stick
|
|
12
|
+
* until wall time caught back up — potentially hours after an NTP correction.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSwapCacheFresh(cache: {
|
|
15
|
+
at: number;
|
|
16
|
+
} | null, now: number, ttlMs?: number): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* `sysctl -n vm.swapusage` as a percentage. Pure, so the arithmetic is testable with the readings
|
|
19
|
+
* the platform can actually produce rather than only the ones a runner happens to have.
|
|
20
|
+
*/
|
|
21
|
+
export declare function swapPercentFromSysctl(stdout: string): number;
|
|
22
|
+
/** One `Win32_PageFileUsage` CSV row as a percentage; see `swapPercentFromSysctl` for the clamp. */
|
|
23
|
+
export declare function swapPercentFromPageFile(stdout: string): number;
|
|
24
|
+
export declare function readSwapUsedPercent(): Promise<number>;
|
|
25
|
+
/**
|
|
26
|
+
* Cumulative CPU time across every core, split into the two halves a utilisation reading needs.
|
|
27
|
+
*
|
|
28
|
+
* `os.cpus()` is the only CPU source common to Linux, macOS and Windows, and each entry is a
|
|
29
|
+
* cumulative* counter since boot — so a percentage is the delta between two snapshots, never a
|
|
30
|
+
* single read. One core busy for the whole window is 100%; all 8 cores busy is 800%, which is why
|
|
31
|
+
* the per-core figure and the machine-wide figure are not interchangeable.
|
|
32
|
+
*/
|
|
33
|
+
export interface CpuTimes {
|
|
34
|
+
/** Milliseconds of CPU time spent doing anything but idling, every core summed. */
|
|
35
|
+
busyMs: number;
|
|
36
|
+
/** Milliseconds of CPU time across every core, idle included. */
|
|
37
|
+
totalMs: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function cpuTimesSnapshot(cpus?: os.CpuInfo[]): CpuTimes;
|
|
40
|
+
/**
|
|
41
|
+
* Share of the machine's CPU capacity in use between two snapshots, 0–100.
|
|
42
|
+
*
|
|
43
|
+
* `null` when the window is empty or the counters went backwards (a suspended host, a clock
|
|
44
|
+
* resync), because "no reading" is honest while a fabricated 0 reads as "idle". Pure, so the
|
|
45
|
+
* arithmetic is testable against snapshots a runner can construct rather than only the one its
|
|
46
|
+
* own scheduler happens to produce.
|
|
47
|
+
*/
|
|
48
|
+
export declare function cpuUsedPercent(previous: CpuTimes, next: CpuTimes): number | null;
|
|
49
|
+
/**
|
|
50
|
+
* Memory used, as a percentage of what the machine actually has.
|
|
51
|
+
*
|
|
52
|
+
* The definition matters more than the arithmetic, and it differs per platform:
|
|
53
|
+
*
|
|
54
|
+
* - Linux: `/proc/meminfo`'s `MemAvailable` already excludes cache, because Linux counts
|
|
55
|
+
* page cache as reclaimable. `os.freemem()` happens to read the same value here.
|
|
56
|
+
* - macOS: **`os.freemem()` is wrong for this.** libuv reports `host_statistics64`'s
|
|
57
|
+
* `free_count` alone, while macOS keeps as much RAM as it can in *inactive* and
|
|
58
|
+
* speculative* pages — file cache it drops on demand. A perfectly healthy Mac therefore
|
|
59
|
+
* reads as 90%+ used, which is the report a user brought back from a 0.7.3 panel. Read
|
|
60
|
+
* `vm_stat` and count what macOS itself counts as available.
|
|
61
|
+
* - Windows: `os.freemem()` is the free physical page count, which is the ordinary reading.
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* How much of `total` is not `free`, as a percentage clamped into `[0, 100]`; 0 when `total` is
|
|
65
|
+
* meaningless.
|
|
66
|
+
*
|
|
67
|
+
* `MemAvailable` is a kernel *estimate* and can exceed `MemTotal`, and `SwapFree` can exceed
|
|
68
|
+
* `SwapTotal` — both make the raw ratio negative. That matters more than a strange display: the
|
|
69
|
+
* alert is `used >= threshold`, so a negative reading silently **suppresses** the memory alert
|
|
70
|
+
* entirely. The fallback branch already clamped for exactly this reason; the `/proc` branch did not,
|
|
71
|
+
* so the two disagreed on the same quantity.
|
|
72
|
+
*/
|
|
73
|
+
export declare function usedPercent(free: number, total: number): number;
|
|
74
|
+
export declare function memoryInfo(vmStat?: string): {
|
|
75
|
+
memoryUsedPercent: number;
|
|
76
|
+
swapUsedPercent: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Which "available memory" reading a platform's fallback should use.
|
|
80
|
+
*
|
|
81
|
+
* Split out from `memoryInfo` because the branch it decides is otherwise unreachable off
|
|
82
|
+
* macOS: Linux answers from `/proc/meminfo` first, so the fallback never runs there and no
|
|
83
|
+
* Linux test can prove which reader was chosen. Taking the platform and the OS reading as
|
|
84
|
+
* arguments makes the decision testable on any runner, which matters — using the wrong
|
|
85
|
+
* reader here is the whole macOS bug.
|
|
86
|
+
*/
|
|
87
|
+
export declare function availableMemoryBytes(platform: NodeJS.Platform, osFree: number, vmStat?: string): number | null;
|
|
88
|
+
/**
|
|
89
|
+
* What macOS counts as available: free + inactive + speculative pages.
|
|
90
|
+
*
|
|
91
|
+
* `vm_stat` reports pages, so the page size is needed — and it is not always 4096 (Apple
|
|
92
|
+
* silicon uses 16384 for the physical page size, and `vm_stat` has printed a `page size of`
|
|
93
|
+
* header since macOS 11). Both are handled: the header when it is there, `getpagesize` when
|
|
94
|
+
* it is not.
|
|
95
|
+
*
|
|
96
|
+
* Returns `null` when the reading cannot be taken, so the caller reports "unknown" rather
|
|
97
|
+
* than inventing a percentage.
|
|
98
|
+
*/
|
|
99
|
+
export declare function macAvailableBytes(vmStat?: string): number | null;
|
|
100
|
+
export interface TemperatureSensor {
|
|
101
|
+
/** The chip or zone name, e.g. `coretemp`, `nvme`, `x86_pkg_temp`. */
|
|
102
|
+
name: string;
|
|
103
|
+
celsius: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The CPU temperature, or null when this machine names no CPU sensor.
|
|
107
|
+
*
|
|
108
|
+
* One tier is chosen and the maximum is taken only *within* it — a CPU package reports several
|
|
109
|
+
* dies, so the hottest die is the reading, but a disk's temperature is not a second opinion.
|
|
110
|
+
*/
|
|
111
|
+
export declare function pickCpuTemperature(sensors: TemperatureSensor[]): number | null;
|
|
112
|
+
/**
|
|
113
|
+
* Best-effort CPU temperature from Linux thermal zones / hwmon. macOS and Windows expose no
|
|
114
|
+
* unprivileged sensor, so those platforms report null and both UIs read "n/a" — a WSL2 guest has
|
|
115
|
+
* none either, and the Windows host's `MSAcpi_ThermalZoneTemperature` answers a constant 20 °C
|
|
116
|
+
* regardless of load, so reaching across for it would be a fabricated number rather than a reading.
|
|
117
|
+
*/
|
|
118
|
+
export declare function cpuTemperature(): number | null;
|
|
119
|
+
/**
|
|
120
|
+
* Run the configured temperature command and parse one number out of its stdout.
|
|
121
|
+
*
|
|
122
|
+
* This is the escape hatch for a machine whose kernel exposes no sensor — a WSL2 guest above all,
|
|
123
|
+
* where `/sys/class/hwmon` is empty and the Windows ACPI zone answers a constant 20 °C. The user
|
|
124
|
+
* supplies the command, so it is spawned without a shell and given a timeout: a hung helper must
|
|
125
|
+
* not stall a sample that the whole panel's tick waits on.
|
|
126
|
+
*
|
|
127
|
+
* Only a whole-number or decimal reading in a plausible range is accepted. Anything else answers
|
|
128
|
+
* null, which the UI reads as `n/a` — never a guess, for the same reason a missing sensor is not
|
|
129
|
+
* published as 0.
|
|
130
|
+
*/
|
|
131
|
+
export declare function temperatureFromCommand(command: string, timeoutMs: number): Promise<number | null>;
|
|
132
|
+
/** The first plausible °C reading in a command's output, or null. Exported for its own tests. */
|
|
133
|
+
export declare function parseTemperature(output: string): number | null;
|
|
134
|
+
/**
|
|
135
|
+
* The temperature to report: the configured command when there is one, else the built-in probe.
|
|
136
|
+
*
|
|
137
|
+
* The command wins even on a platform whose probe works, because a person who set it did so to
|
|
138
|
+
* override what the panel found.
|
|
139
|
+
*/
|
|
140
|
+
export declare function readTemperature(config: HostConfig): Promise<number | null>;
|
|
141
|
+
/**
|
|
142
|
+
* Samples the machine itself: the failures a home server actually dies from are
|
|
143
|
+
* a full disk, exhausted memory or a runaway load — none of which a port probe
|
|
144
|
+
* can see.
|
|
145
|
+
*/
|
|
146
|
+
export declare function sampleHost(config: HostConfig, resolvePath: (target: string) => string): Promise<HostView>;
|
|
147
|
+
export declare function emptyHostView(config: HostConfig): HostView;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** What the panel actually spawned for an entry: the argv it has to recognize again. */
|
|
2
|
+
export interface SpawnInfo {
|
|
3
|
+
command: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
cwd: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Splits a command line into words, undoing the quoting Windows put there. `CommandLine`
|
|
9
|
+
* is the raw string from the spawn call, so `"C:\a b\x.cmd" /c` is one argv entry plus
|
|
10
|
+
* two words, and a quoted argument that contains spaces has to come back as one word.
|
|
11
|
+
*
|
|
12
|
+
* Windows also *escapes* a quote inside an argument as `\"` (Node does this for any argv
|
|
13
|
+
* containing a quote), so the escape is undone here — otherwise every argument with a
|
|
14
|
+
* quote in it survives as a stray backslash and never matches what the panel spawned.
|
|
15
|
+
*/
|
|
16
|
+
export declare function splitCommandLine(line: string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* True when the argv a process is running is the entry's own: the image must match where
|
|
19
|
+
* `spawn` would have looked it up — the image Path, or the first word of the command line
|
|
20
|
+
* — and the words after it must open with the entry's args, compared literally. So
|
|
21
|
+
* `spawn --port 4000` also covers `spawn -p 4000 --extra`, which is what a self-restarting
|
|
22
|
+
* wrapper does, while `/tmp/evil/server.js` never covers `/srv/web/server.js` — two paths that name
|
|
23
|
+
* a directory are different files, and the basename fallback applies only while one spelling is bare
|
|
24
|
+
* (see `sameWord`).
|
|
25
|
+
*
|
|
26
|
+
* `words` must already be the process's own argv. A command-line *string* is only correct
|
|
27
|
+
* on Windows, where the OS hands one out; `/proc/<pid>/cmdline` quotes are literal bytes
|
|
28
|
+
* of an argument, so re-joining that argv into one string corrupts it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchesSpawn(info: {
|
|
31
|
+
words: string[];
|
|
32
|
+
imagePath?: string | null;
|
|
33
|
+
}, spawn: SpawnInfo): boolean;
|
|
34
|
+
/** The argv of a pid on the platforms whose process table can answer it; null otherwise. */
|
|
35
|
+
export declare function processArgv(pid: number): Promise<string[] | null>;
|
|
36
|
+
/**
|
|
37
|
+
* `Win32_Process` for one pid, or null when it cannot be read.
|
|
38
|
+
*
|
|
39
|
+
* The whole round trip — launching PowerShell, loading the CIM provider, serializing —
|
|
40
|
+
* costs seconds on a cold runner, so the timeout is generous and the result is converted
|
|
41
|
+
* to CSV rather than JSON: CSV survives a value that contains a quote or a newline, which
|
|
42
|
+
* an argv legitimately can.
|
|
43
|
+
*/
|
|
44
|
+
export declare function windowsProcessInfo(pid: number): Promise<{
|
|
45
|
+
commandLine: string;
|
|
46
|
+
imagePath: string | null;
|
|
47
|
+
} | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Which of these pids look like this entry's own detached successor. The environment
|
|
50
|
+
* marker is authoritative where the platform can read it; otherwise the answer rests on
|
|
51
|
+
* the entry's own argv, which is the only signal a detached successor is obliged to keep
|
|
52
|
+
* — and the only one Windows exposes at all.
|
|
53
|
+
*/
|
|
54
|
+
export declare function identifyHolders(serverId: string, spawn: SpawnInfo, pids: number[]): Promise<number[]>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { LogLine } from '../shared/contracts.js';
|
|
2
|
+
export declare class LogTailer {
|
|
3
|
+
private readonly file;
|
|
4
|
+
private offset;
|
|
5
|
+
private identity;
|
|
6
|
+
/** The file being read, held open so a rotation cannot take its unread tail away. */
|
|
7
|
+
private fd;
|
|
8
|
+
private carry;
|
|
9
|
+
/** The file is one byte stream: a read budget can end inside a multibyte character. */
|
|
10
|
+
private readonly decoder;
|
|
11
|
+
constructor(file: string);
|
|
12
|
+
/** Bytes consumed so far; equal to the file size once it has been drained. */
|
|
13
|
+
get position(): number;
|
|
14
|
+
/** Start from the beginning again — used when a fresh process takes the entry over. */
|
|
15
|
+
reset(): void;
|
|
16
|
+
/** Releases the descriptor. A later `read()` reopens the path. */
|
|
17
|
+
close(): void;
|
|
18
|
+
/**
|
|
19
|
+
* The last `count` lines, with the read position moved to the end of the file in the
|
|
20
|
+
* same operation.
|
|
21
|
+
*
|
|
22
|
+
* A panel attaching to a running entry wants both a backfill and a live stream, and
|
|
23
|
+
* only one thing may own the offset. Reading the tail through the same tailer is what
|
|
24
|
+
* keeps a line from being replayed as news or skipped as history — and it is why this
|
|
25
|
+
* does not delegate to `LogFiles.readTail()`, which knows nothing of this position.
|
|
26
|
+
*/
|
|
27
|
+
readTailLines(count: number): LogLine[];
|
|
28
|
+
/**
|
|
29
|
+
* Ignore what is already in the file and follow it from here.
|
|
30
|
+
*/
|
|
31
|
+
skipToEnd(): void;
|
|
32
|
+
/** Every complete line written since the previous call. */
|
|
33
|
+
read(): LogLine[];
|
|
34
|
+
/** Opens the path and moves to its end, dropping anything held from an earlier file. */
|
|
35
|
+
private attachAtEnd;
|
|
36
|
+
/**
|
|
37
|
+
* Opens whatever the path names now. A file other than the one last read starts at 0;
|
|
38
|
+
* reopening the same one (after `close()`) keeps the position. `replaced` says the caller
|
|
39
|
+
* already knows it is another file, whatever its identity reads.
|
|
40
|
+
*/
|
|
41
|
+
private openPath;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the path now names a different file than the open descriptor — or none.
|
|
44
|
+
*
|
|
45
|
+
* Identity alone is not trusted: where `ino` is 0 the birth time stands in for it and can
|
|
46
|
+
* collide, so a path *smaller* than the open file (stat'd after it, so a same-file reading can
|
|
47
|
+
* only be larger) is a different file too.
|
|
48
|
+
*/
|
|
49
|
+
private pathReplaced;
|
|
50
|
+
private drained;
|
|
51
|
+
/** Reads the open file from `offset` towards its end, up to `budget` bytes; returns bytes read. */
|
|
52
|
+
private drain;
|
|
53
|
+
/** Forget a half-seen line (and character): the bytes that would complete it are gone. */
|
|
54
|
+
private dropCarry;
|
|
55
|
+
private consume;
|
|
56
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { NannyState, StopConfig } from '../shared/contracts.js';
|
|
2
|
+
import { nannyChildPid } from './nanny.js';
|
|
3
|
+
import { terminatePid } from './process.js';
|
|
4
|
+
/**
|
|
5
|
+
* Finds and ends the persistent entries a host is running, with no panel in the loop.
|
|
6
|
+
*
|
|
7
|
+
* `down` leaves these alone on purpose, so `--with-persistent` is the one caller that has to
|
|
8
|
+
* act on them — often after the panel is already gone. The nanny state files are the only
|
|
9
|
+
* record that survives that, and they are per workspace, so every workspace is read.
|
|
10
|
+
*
|
|
11
|
+
* The **nanny** is what gets signalled: it traps the signal and forwards the entry's own
|
|
12
|
+
* `stop` policy to the child it owns, which is what the panel's stop does. That is also why
|
|
13
|
+
* this cannot go through `/_hh` — after a crash there is nothing left to ask.
|
|
14
|
+
*/
|
|
15
|
+
/** One live persistent entry, as its state file describes it. */
|
|
16
|
+
export interface PersistentHandle {
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
serverId: string;
|
|
19
|
+
state: NannyState;
|
|
20
|
+
/** The workspace's `.state` directory, which owns the state file. */
|
|
21
|
+
dir: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The persistent entries whose nanny is running right now.
|
|
25
|
+
*
|
|
26
|
+
* A `<id>.run.json` file is a *non-persistent* child's own record and carries no nanny, so it
|
|
27
|
+
* is skipped by suffix — the same distinction `backup-offline` relies on. `nannyIsAlive` is
|
|
28
|
+
* the identity check: a live pid alone proves nothing, since pids are reused.
|
|
29
|
+
*/
|
|
30
|
+
export declare function livePersistentEntries(hhDir: string): Promise<PersistentHandle[]>;
|
|
31
|
+
/** What one stop did, so a survivor is reported rather than dressed up as success. */
|
|
32
|
+
export interface PersistentStop {
|
|
33
|
+
handle: PersistentHandle;
|
|
34
|
+
stopped: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Stops these entries and consumes the record of each one that ended.
|
|
39
|
+
*
|
|
40
|
+
* `stopFor` is the entry's own `stop` config, read by the caller from the workspace that
|
|
41
|
+
* declares it: the grace period here has to be the one the entry asked for, or a stop that
|
|
42
|
+
* was still finishing its shutdown reads as a failure and escalates to `SIGKILL`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function stopPersistentEntries(handles: PersistentHandle[], options?: {
|
|
45
|
+
stopFor?: (handle: PersistentHandle) => StopConfig;
|
|
46
|
+
/**
|
|
47
|
+
* The one thing a test cannot supply: `SIGKILL` is not survivable, and a pid this process
|
|
48
|
+
* may not signal (the real survivor) is a second user this host has no way to create. The
|
|
49
|
+
* seam is the terminator, not the decision — everything below still runs.
|
|
50
|
+
*/
|
|
51
|
+
terminate?: typeof terminatePid;
|
|
52
|
+
/** Whether the state's child pid is still the process the nanny spawned (`nannyChildPid`). */
|
|
53
|
+
childPid?: typeof nannyChildPid;
|
|
54
|
+
}): Promise<PersistentStop[]>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ProcessBirth } from './port.js';
|
|
2
|
+
import type { TerminateOptions } from './process.js';
|
|
3
|
+
import type { NannyExit, NannySpec, NannyState, StopConfig } from '../shared/contracts.js';
|
|
4
|
+
/** Suffix of a spawn spec, so a sweep and the state reader can tell them apart. */
|
|
5
|
+
export declare const SPEC_SUFFIX = ".spec.json";
|
|
6
|
+
/**
|
|
7
|
+
* The signals a nanny traps and forwards to its child. Any other signal ends the nanny outright,
|
|
8
|
+
* so nothing was forwarded — see `stopPersistentEntries`, which then signals the child directly.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NANNY_TRAPPED_SIGNALS: ReadonlySet<NodeJS.Signals>;
|
|
11
|
+
/**
|
|
12
|
+
* How a nanny is stopped. A trapped signal goes to the nanny's pid alone and the nanny signals its
|
|
13
|
+
* own group once (`killGroup` is honoured there): signalling the group from here as well delivered
|
|
14
|
+
* the stop to the child twice. The SIGKILL escalation still covers the whole group. Windows has no
|
|
15
|
+
* signal a nanny can trap, so its stop is unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function nannyStopOptions(stop: StopConfig, platform?: NodeJS.Platform): TerminateOptions;
|
|
18
|
+
/** How often a nanny rewrites its state file. */
|
|
19
|
+
export declare const NANNY_HEARTBEAT_MS = 5000;
|
|
20
|
+
/** A heartbeat older than this is not evidence of anything. */
|
|
21
|
+
export declare const HEARTBEAT_STALE_MS = 30000;
|
|
22
|
+
/**
|
|
23
|
+
* The state directory is passed in rather than read from a global: the panel injects
|
|
24
|
+
* `$HHOSTED_HOME/.state`, and a test injects its own temp directory.
|
|
25
|
+
*/
|
|
26
|
+
export declare function nannySpecPath(dir: string, id: string): string;
|
|
27
|
+
export declare function nannyStatePath(dir: string, id: string): string;
|
|
28
|
+
/** The file a nanny writes and the panel tails; one derivation, so they cannot drift. */
|
|
29
|
+
export declare function nannyLogFile(logDir: string, id: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* How to run this CLI again as a nanny. The panel was itself launched through this
|
|
32
|
+
* entry point (`up` re-spawns itself with it), so `process.argv[1]` is the one path
|
|
33
|
+
* that works under tsx, from `dist/cli.js` and through the published bin alike.
|
|
34
|
+
*/
|
|
35
|
+
export declare function nannyEntryPoint(): string;
|
|
36
|
+
/** Written before the spawn, consumed by the nanny, never left behind. */
|
|
37
|
+
export declare function writeNannySpec(file: string, spec: NannySpec): void;
|
|
38
|
+
export declare function clearNannySpec(file: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* Reads and unlinks in one step: the spec holds expanded secrets, and a spec left
|
|
41
|
+
* behind — a nanny that died before reading it, a panel killed mid-spawn — is a
|
|
42
|
+
* secret file with no owner. It is consumed even when it cannot be parsed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function takeNannySpec(file: string): NannySpec;
|
|
45
|
+
/**
|
|
46
|
+
* Nothing can be waiting on a spec before this panel has spawned a nanny, so every
|
|
47
|
+
* one still on disk at boot belongs to a nanny that never read it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function sweepNannySpecs(dir: string): number;
|
|
50
|
+
/** A stale or foreign file reads as "no state", never as a throw. */
|
|
51
|
+
export declare function readNannyState(file: string): NannyState | null;
|
|
52
|
+
export declare function writeNannyState(file: string, state: NannyState): void;
|
|
53
|
+
export declare function clearNannyState(file: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* The same wording the supervisor uses for a child's exit, so history reads alike — plus a hint
|
|
56
|
+
* when the code has a conventional meaning, because `code 137` alone tells an operator nothing and
|
|
57
|
+
* that is the one they most want explained (a container limit or the kernel OOM killer).
|
|
58
|
+
*
|
|
59
|
+
* The hint is worded as a possibility, never a claim: 128+N is a shell convention, and a program
|
|
60
|
+
* is free to exit 137 for its own reasons — a JVM reports OOM that way itself. 126 and 127 are
|
|
61
|
+
* firmer, since the shell sets those when it cannot run the command at all.
|
|
62
|
+
*/
|
|
63
|
+
export declare function describeNannyExit(exit: NannyExit): string;
|
|
64
|
+
/**
|
|
65
|
+
* A spawn failure in words a person can act on.
|
|
66
|
+
*
|
|
67
|
+
* Node reports a missing program as `spawn <cmd> ENOENT` — the same errno as a missing *file*, and
|
|
68
|
+
* the same wording whichever of the two it is. A user who pasted `java -jar server.jar` into
|
|
69
|
+
* `command` saw exactly that and had nothing to go on: the message names the whole line, so it
|
|
70
|
+
* reads as "the program is missing" even when the program is fine and only the argument is wrong.
|
|
71
|
+
*
|
|
72
|
+
* `command` is the configured program, so the two cases can be told apart: if a bare name has no
|
|
73
|
+
* path separator, the shell would have searched `PATH` and this one did not.
|
|
74
|
+
*
|
|
75
|
+
* A **missing working directory** is the third cause of the same errno, and it is the one a
|
|
76
|
+
* deployment hits: `spawn` resolves `cwd` before it looks for the program, so an entry whose `cwd`
|
|
77
|
+
* does not exist *under this launch directory* fails exactly like an uninstalled program. That read
|
|
78
|
+
* sent a person to `which node` while `node` was fine and only the relative path was wrong (a unit
|
|
79
|
+
* file with no `WorkingDirectory=`, a container started from `/`). `cwd` is therefore checked first:
|
|
80
|
+
* if it is not an existing directory, nothing else about the spawn could have worked.
|
|
81
|
+
*/
|
|
82
|
+
export declare function describeSpawnError(error: NodeJS.ErrnoException, command: string, cwd?: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Is the nanny this state describes still ours? A live pid proves nothing on its
|
|
85
|
+
* own — pids are reused, and the heartbeat is written *into the file*, not by the
|
|
86
|
+
* process the file names, so a recycled pid with a recent write reads as running.
|
|
87
|
+
* `startedAt` settles that first (`processLiveness`), exactly as `run.json` uses it:
|
|
88
|
+
* the nanny stamps its record during its own boot, so its process is always born
|
|
89
|
+
* before the stamp. The environment marker (Linux, macOS) or the argv we spawned it
|
|
90
|
+
* with answers the rest, Windows included.
|
|
91
|
+
*/
|
|
92
|
+
export declare function nannyIsAlive(state: NannyState, id: string, options?: {
|
|
93
|
+
readBirth?: (pid: number) => Promise<ProcessBirth | null>;
|
|
94
|
+
}): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* The nanny's child, when that pid is still the process it spawned — `null` otherwise. Used to stop a
|
|
97
|
+
* child the nanny could not pass a stop on to, which happens *after* the nanny is gone, so a pid alone
|
|
98
|
+
* could be anybody's by then. The nanny stamps `startedAt` just before it spawns the child, so the
|
|
99
|
+
* child is born within the stamp's tolerance and a pid born later is a recycled one. Where the
|
|
100
|
+
* platform reports no birth, the environment marker decides.
|
|
101
|
+
*/
|
|
102
|
+
export declare function nannyChildPid(state: NannyState, options?: {
|
|
103
|
+
readBirth?: (pid: number) => Promise<ProcessBirth | null>;
|
|
104
|
+
}): Promise<number | null>;
|