@rocket.chat/houston 0.27.0-next.2 → 2.1.8
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/LICENSE +1 -1
- package/README.md +108 -15
- package/bin/houston +62 -0
- package/data/docs/ARCHITECTURE.md +387 -0
- package/data/docs/automation.md +107 -0
- package/data/docs/e2ee.md +76 -0
- package/data/docs/eks.md +258 -0
- package/data/docs/gui.md +282 -0
- package/data/docs/guide.md +669 -0
- package/data/docs/kubernetes.md +138 -0
- package/data/docs/troubleshooting.md +193 -0
- package/data/docs/upgrading.md +84 -0
- package/data/docs/voice.md +253 -0
- package/data/iam/engineer-policy.json +11 -0
- package/data/iam/engineer-rbac.yaml +42 -0
- package/data/iam/operator-policy.json +211 -0
- package/data/loadtest/badbot.js +22 -0
- package/data/loadtest/common.js +168 -0
- package/data/loadtest/custom.js +20 -0
- package/data/loadtest/journey.js +58 -0
- package/data/loadtest/login.js +18 -0
- package/data/loadtest/messages.js +13 -0
- package/data/loadtest/mixed.js +39 -0
- package/data/loadtest/read.js +12 -0
- package/data/loadtest/webhook.js +20 -0
- package/data/monitoring/houston-logs.json +98 -0
- package/data/monitoring/k6-loadtest.json +610 -0
- package/data/monitoring/mongodb-exporter.json +3007 -0
- package/data/monitoring/node-exporter-full.json +16114 -0
- package/data/monitoring/rocketchat-metrics.json +6471 -0
- package/data/presets/airgapped.yaml +16 -0
- package/data/presets/default.yaml +9 -0
- package/data/seed/avatar-0.png +0 -0
- package/data/seed/avatar-1.png +0 -0
- package/data/seed/avatar-2.png +0 -0
- package/data/seed/avatar-3.png +0 -0
- package/data/seed/avatar-4.png +0 -0
- package/data/seed/avatar-5.png +0 -0
- package/data/seed/avatar-6.png +0 -0
- package/data/seed/avatar-7.png +0 -0
- package/data/seed/seed-metrics.csv +3 -0
- package/data/seed/seed-preview.png +0 -0
- package/data/seed/seed-report.pdf +32 -0
- package/data/seed/seed-runbook.txt +3 -0
- package/data/skill/SKILL.md +399 -0
- package/data/versions.yaml +55 -0
- package/data/voice/freeswitch/drachtio.xml +52 -0
- package/data/voice/freeswitch/public.xml +87 -0
- package/data/webui/app.css +2003 -0
- package/data/webui/index.html +678 -0
- package/data/webui/js/api.js +561 -0
- package/data/webui/js/boot.js +44 -0
- package/data/webui/js/clusters-tail.js +1377 -0
- package/data/webui/js/clusters.js +896 -0
- package/data/webui/js/create.js +276 -0
- package/data/webui/js/detail.js +507 -0
- package/data/webui/js/jobs.js +636 -0
- package/data/webui/js/logs.js +634 -0
- package/data/webui/js/main.js +14 -0
- package/data/webui/js/options.js +408 -0
- package/data/webui/js/people.js +438 -0
- package/data/webui/js/perf.js +303 -0
- package/data/webui/js/render.js +438 -0
- package/data/webui/js/shared.js +3 -0
- package/data/webui/js/state.js +583 -0
- package/data/webui/js/theme.js +123 -0
- package/data/webui/js/util.js +584 -0
- package/dist/cli/app.js +593 -0
- package/dist/cli/capabilities.js +76 -0
- package/dist/cli/cell-widths.js +495 -0
- package/dist/cli/entry.js +10 -0
- package/dist/cli/error-panel.js +492 -0
- package/dist/cli/handlers/actor.js +84 -0
- package/dist/cli/handlers/https.js +614 -0
- package/dist/cli/handlers/prompt.js +299 -0
- package/dist/cli/handlers/users.js +226 -0
- package/dist/cli/handlers.js +3678 -0
- package/dist/cli/help.js +183 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/perf.js +810 -0
- package/dist/cli/render.js +254 -0
- package/dist/cli/serve.js +858 -0
- package/dist/cli/spec-data.js +2593 -0
- package/dist/cli/spec-types.js +8 -0
- package/dist/cli/usage-error.js +520 -0
- package/dist/cli/wire.js +70 -0
- package/dist/core/audit.js +346 -0
- package/dist/core/backup-compat.js +85 -0
- package/dist/core/backup.js +1639 -0
- package/dist/core/cluster.js +1398 -0
- package/dist/core/configimport.js +344 -0
- package/dist/core/data.js +267 -0
- package/dist/core/database-of.js +82 -0
- package/dist/core/diagnose.js +159 -0
- package/dist/core/doctor.js +1518 -0
- package/dist/core/edge/acme.js +338 -0
- package/dist/core/edge/engine.js +500 -0
- package/dist/core/edge/networks.js +174 -0
- package/dist/core/edge/paths.js +107 -0
- package/dist/core/edge/routes.js +251 -0
- package/dist/core/edge/routeyml.js +195 -0
- package/dist/core/edge/runtime.js +493 -0
- package/dist/core/edge/spec.js +305 -0
- package/dist/core/edge/types.js +202 -0
- package/dist/core/eks-docs.js +135 -0
- package/dist/core/eks.js +2240 -0
- package/dist/core/envvars.js +562 -0
- package/dist/core/eventlog.js +541 -0
- package/dist/core/firstrun.js +153 -0
- package/dist/core/journal.js +691 -0
- package/dist/core/kube/ask.js +231 -0
- package/dist/core/kube/capabilities.js +269 -0
- package/dist/core/kube/certmanager.js +452 -0
- package/dist/core/kube/chart.js +413 -0
- package/dist/core/kube/cluster.js +196 -0
- package/dist/core/kube/context.js +545 -0
- package/dist/core/kube/endpoints.js +448 -0
- package/dist/core/kube/exec.js +195 -0
- package/dist/core/kube/forward.js +732 -0
- package/dist/core/kube/grafana-ingress.js +110 -0
- package/dist/core/kube/ingress.js +218 -0
- package/dist/core/kube/manifests.js +361 -0
- package/dist/core/kube/monitoring.js +768 -0
- package/dist/core/kube/names.js +237 -0
- package/dist/core/kube/namespace.js +678 -0
- package/dist/core/kube/operator.js +941 -0
- package/dist/core/kube/probe.js +202 -0
- package/dist/core/kube/reachability.js +163 -0
- package/dist/core/kube/release.js +439 -0
- package/dist/core/kube/replicaset.js +180 -0
- package/dist/core/kube/scale.js +398 -0
- package/dist/core/kube/status.js +633 -0
- package/dist/core/kube/tools.js +238 -0
- package/dist/core/kube/transfer.js +173 -0
- package/dist/core/kube/workspace.js +423 -0
- package/dist/core/lifecycle/admin.js +64 -0
- package/dist/core/lifecycle/create-docker.js +1533 -0
- package/dist/core/lifecycle/create-k8s.js +939 -0
- package/dist/core/lifecycle/destroy.js +339 -0
- package/dist/core/lifecycle/inspect.js +635 -0
- package/dist/core/lifecycle/naming.js +298 -0
- package/dist/core/lifecycle/notes.js +726 -0
- package/dist/core/lifecycle/ownership.js +313 -0
- package/dist/core/lifecycle/payload.js +401 -0
- package/dist/core/lifecycle/ports.js +388 -0
- package/dist/core/lifecycle/preconditions.js +367 -0
- package/dist/core/lifecycle/pruning.js +551 -0
- package/dist/core/lifecycle/ready.js +753 -0
- package/dist/core/lifecycle/request.js +525 -0
- package/dist/core/lifecycle/seeding.js +281 -0
- package/dist/core/lifecycle/sizing.js +392 -0
- package/dist/core/lifecycle/state.js +286 -0
- package/dist/core/lifecycle/tlsplan.js +704 -0
- package/dist/core/lifecycle/types.js +232 -0
- package/dist/core/loadtest.js +995 -0
- package/dist/core/migrate.js +612 -0
- package/dist/core/monitor.js +494 -0
- package/dist/core/postready.js +969 -0
- package/dist/core/promote.js +804 -0
- package/dist/core/rcapi.js +1285 -0
- package/dist/core/recovery.js +75 -0
- package/dist/core/runner/engine.js +394 -0
- package/dist/core/runner/host.js +298 -0
- package/dist/core/runner/locks.js +129 -0
- package/dist/core/runner/paths.js +173 -0
- package/dist/core/runner/ports.js +172 -0
- package/dist/core/runner/queries.js +612 -0
- package/dist/core/runner/record.js +563 -0
- package/dist/core/scaleseed.js +271 -0
- package/dist/core/seed-db.js +208 -0
- package/dist/core/sessions.js +472 -0
- package/dist/core/skill.js +326 -0
- package/dist/core/sso-identities.js +172 -0
- package/dist/core/sso.js +703 -0
- package/dist/core/tls-local.js +311 -0
- package/dist/core/tls.js +878 -0
- package/dist/core/topology.js +482 -0
- package/dist/core/upgrade.js +868 -0
- package/dist/core/users.js +739 -0
- package/dist/lib/audit.js +100 -0
- package/dist/lib/close-matches.js +238 -0
- package/dist/lib/compose.js +672 -0
- package/dist/lib/config.js +1398 -0
- package/dist/lib/context.js +18 -0
- package/dist/lib/errors.js +305 -0
- package/dist/lib/events.js +208 -0
- package/dist/lib/float-text.js +126 -0
- package/dist/lib/format.js +1320 -0
- package/dist/lib/home.js +325 -0
- package/dist/lib/journal.js +122 -0
- package/dist/lib/json-text.js +733 -0
- package/dist/lib/jsonout.js +382 -0
- package/dist/lib/lock.js +516 -0
- package/dist/lib/login-name.js +202 -0
- package/dist/lib/map-limit.js +29 -0
- package/dist/lib/mkdir-parents.js +90 -0
- package/dist/lib/mongo-kernel.js +67 -0
- package/dist/lib/monitoring.js +492 -0
- package/dist/lib/platform-name.js +59 -0
- package/dist/lib/presets/common.js +390 -0
- package/dist/lib/presets/composite.js +326 -0
- package/dist/lib/presets/e2ee.js +143 -0
- package/dist/lib/presets/email.js +172 -0
- package/dist/lib/presets/guides.js +27 -0
- package/dist/lib/presets/index.js +490 -0
- package/dist/lib/presets/keycloak.js +369 -0
- package/dist/lib/presets/ldap.js +1285 -0
- package/dist/lib/presets/livechat.js +220 -0
- package/dist/lib/presets/multi-instance.js +124 -0
- package/dist/lib/presets/oidc.js +161 -0
- package/dist/lib/presets/public.js +496 -0
- package/dist/lib/presets/registry.js +64 -0
- package/dist/lib/presets/s3-minio.js +300 -0
- package/dist/lib/presets/saml.js +149 -0
- package/dist/lib/presets/scenario.js +51 -0
- package/dist/lib/presets/types.js +86 -0
- package/dist/lib/presets/voice-pbx.js +320 -0
- package/dist/lib/presets/voice.js +345 -0
- package/dist/lib/presets/webhooks.js +182 -0
- package/dist/lib/redact.js +106 -0
- package/dist/lib/seed-options.js +68 -0
- package/dist/lib/seed-profiles.js +59 -0
- package/dist/lib/targz.js +1383 -0
- package/dist/lib/teammode.js +25 -0
- package/dist/lib/tempdir.js +162 -0
- package/dist/lib/unicode-tables.js +2335 -0
- package/dist/lib/version-spec.js +357 -0
- package/dist/lib/versions.js +463 -0
- package/dist/lib/yaml-dump.js +1361 -0
- package/dist/perf/baseline.js +168 -0
- package/dist/perf/constrain.js +296 -0
- package/dist/perf/k6.js +235 -0
- package/dist/perf/mongoprof.js +171 -0
- package/dist/perf/rcmetrics.js +178 -0
- package/dist/perf/report.js +386 -0
- package/dist/perf/resources.js +224 -0
- package/dist/perf/slo.js +111 -0
- package/dist/perf/timeline.js +187 -0
- package/dist/perf/timings.js +85 -0
- package/dist/perf/verdict.js +201 -0
- package/dist/seams/aws-cli.js +126 -0
- package/dist/seams/docker-cli.js +280 -0
- package/dist/seams/exec.js +861 -0
- package/dist/seams/fs/lock.js +528 -0
- package/dist/seams/kubectl.js +83 -0
- package/dist/seams/rc-http.js +921 -0
- package/dist/seed/apply.js +190 -0
- package/dist/seed/assets.js +76 -0
- package/dist/seed/check.js +391 -0
- package/dist/seed/client.js +172 -0
- package/dist/seed/executor.js +726 -0
- package/dist/seed/history.js +281 -0
- package/dist/seed/kinds.js +91 -0
- package/dist/seed/plan.js +432 -0
- package/dist/seed/receipt.js +339 -0
- package/dist/seed/repairs.js +75 -0
- package/dist/seed/verification.js +363 -0
- package/dist/seed/wording.js +248 -0
- package/dist/web/app.js +326 -0
- package/dist/web/jobs.js +510 -0
- package/dist/web/route-deps.js +211 -0
- package/dist/web/route-table.js +213 -0
- package/dist/web/routes/backup.js +244 -0
- package/dist/web/routes/clusters.js +303 -0
- package/dist/web/routes/data.js +187 -0
- package/dist/web/routes/edge.js +82 -0
- package/dist/web/routes/index.js +63 -0
- package/dist/web/routes/jobs.js +95 -0
- package/dist/web/routes/logs.js +297 -0
- package/dist/web/routes/meta.js +191 -0
- package/dist/web/routes/people.js +151 -0
- package/dist/web/routes/perf.js +95 -0
- package/dist/web/routes/repros.js +550 -0
- package/dist/web/routes/session.js +361 -0
- package/dist/web/routes/spa.js +198 -0
- package/dist/web/security.js +475 -0
- package/dist/web/signin.js +246 -0
- package/package.json +67 -32
- package/.eslintrc +0 -94
- package/.swcrc +0 -18
- package/dist/bin.js +0 -3
- package/dist/cli.js +0 -184
- package/dist/commands/createBranch.js +0 -192
- package/src/bin.js +0 -4
- package/src/cli.ts +0 -25
- package/src/commands/createBranch.ts +0 -25
- package/src-old/logs.js +0 -323
- package/src-old/md.js +0 -191
- package/src-old/release-table.js +0 -60
- package/src-old/set-version.js +0 -614
- package/src-old/utils.js +0 -15
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runningWriterServices = runningWriterServices;
|
|
37
|
+
exports.removeVolumes = removeVolumes;
|
|
38
|
+
exports.dockerStats = dockerStats;
|
|
39
|
+
exports.rcState = rcState;
|
|
40
|
+
exports.composeLs = composeLs;
|
|
41
|
+
exports.projectStates = projectStates;
|
|
42
|
+
exports.projectConfigFiles = projectConfigFiles;
|
|
43
|
+
exports.projectDataVolumes = projectDataVolumes;
|
|
44
|
+
exports.rcContainerEnv = rcContainerEnv;
|
|
45
|
+
exports.networklessContainers = networklessContainers;
|
|
46
|
+
exports.startErrors = startErrors;
|
|
47
|
+
exports.oneShotSetups = oneShotSetups;
|
|
48
|
+
exports.rcRestartCount = rcRestartCount;
|
|
49
|
+
exports.servicesByProject = servicesByProject;
|
|
50
|
+
exports.servicesByProjectUncached = servicesByProjectUncached;
|
|
51
|
+
exports.rcStatusByProject = rcStatusByProject;
|
|
52
|
+
exports.containerDetails = containerDetails;
|
|
53
|
+
/**
|
|
54
|
+
* Read-only questions about what Docker is actually running.
|
|
55
|
+
*
|
|
56
|
+
* Two contracts recur and they are not the same: a function that returns `null` distinguishes
|
|
57
|
+
* "could not ask Docker" from "the answer is empty", and one that returns `{}` or `''` has
|
|
58
|
+
* decided those are the same. Which is which is load-bearing -- `prune` DELETES based on
|
|
59
|
+
* absence, so it must never read a failed query as "no projects".
|
|
60
|
+
*/
|
|
61
|
+
const errors_1 = require("../../lib/errors");
|
|
62
|
+
const format_1 = require("../../lib/format");
|
|
63
|
+
const json_text_1 = require("../../lib/json-text");
|
|
64
|
+
const float_text_1 = require("../../lib/float-text");
|
|
65
|
+
const docker_cli_1 = require("../../seams/docker-cli");
|
|
66
|
+
const exec_1 = require("../../seams/exec");
|
|
67
|
+
const engine = __importStar(require("./engine"));
|
|
68
|
+
const record_1 = require("./record");
|
|
69
|
+
/** A strict writer query: failed or malformed discovery must never authorize a dump/drop. */
|
|
70
|
+
async function runningWriterServices(name, services) {
|
|
71
|
+
if (services.length === 0)
|
|
72
|
+
throw new errors_1.DockerError(`'${name}' has no Rocket.Chat services`);
|
|
73
|
+
const result = await engine.compose(name, ['ps', '--all', '--format', 'json', ...services], {
|
|
74
|
+
capture: true,
|
|
75
|
+
timeoutMs: 30000,
|
|
76
|
+
});
|
|
77
|
+
if (result.exitCode !== 0) {
|
|
78
|
+
throw new errors_1.DockerError(`could not inspect Rocket.Chat writers for '${name}': ${String(result.stderr ?? '').trim()}`);
|
|
79
|
+
}
|
|
80
|
+
const raw = String(result.stdout ?? '').trim();
|
|
81
|
+
let rows;
|
|
82
|
+
try {
|
|
83
|
+
let parsed;
|
|
84
|
+
try {
|
|
85
|
+
parsed = raw === '' ? [] : JSON.parse(raw);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
parsed = raw.split('\n').map((line) => JSON.parse(line));
|
|
89
|
+
}
|
|
90
|
+
rows = Array.isArray(parsed) ? parsed : [parsed];
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
throw new errors_1.DockerError(`could not inspect Rocket.Chat writers for '${name}': invalid container list`);
|
|
94
|
+
}
|
|
95
|
+
const running = new Set();
|
|
96
|
+
for (const row of rows) {
|
|
97
|
+
if (typeof row !== 'object' || row === null || Array.isArray(row)) {
|
|
98
|
+
throw new errors_1.DockerError(`could not inspect Rocket.Chat writers for '${name}': invalid container row`);
|
|
99
|
+
}
|
|
100
|
+
const item = row;
|
|
101
|
+
if (typeof item.Service !== 'string' || typeof item.State !== 'string') {
|
|
102
|
+
throw new errors_1.DockerError(`could not inspect Rocket.Chat writers for '${name}': missing container state`);
|
|
103
|
+
}
|
|
104
|
+
if (!services.includes(item.Service))
|
|
105
|
+
continue;
|
|
106
|
+
if (item.State === 'running' || item.State === 'restarting')
|
|
107
|
+
running.add(item.Service);
|
|
108
|
+
else if (!['exited', 'dead', 'created'].includes(item.State)) {
|
|
109
|
+
throw new errors_1.DockerError(`could not inspect Rocket.Chat writers for '${name}': unsupported state '${item.State}'`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return services.filter((service) => running.has(service));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Delete named volumes belonging to a repro's compose project.
|
|
116
|
+
*
|
|
117
|
+
* `docker compose down -v` only removes volumes DECLARED in the compose file, so a
|
|
118
|
+
* volume whose declaration is dropped (detaching monitoring, switching preset with
|
|
119
|
+
* --force) becomes unreachable and survives forever. Containers must be gone first.
|
|
120
|
+
* Returns the volume names that could not be removed.
|
|
121
|
+
*/
|
|
122
|
+
async function removeVolumes(name, volumes) {
|
|
123
|
+
const project = await (0, record_1.projectName)(name);
|
|
124
|
+
const failed = [];
|
|
125
|
+
for (const volume of volumes) {
|
|
126
|
+
const full = `${project}_${volume}`;
|
|
127
|
+
try {
|
|
128
|
+
const result = await (0, docker_cli_1.docker)(['volume', 'rm', full], { capture: true, timeoutMs: 30000 });
|
|
129
|
+
// Already gone is success, not a failure.
|
|
130
|
+
if (result.exitCode !== 0 &&
|
|
131
|
+
!String(result.stderr ?? '')
|
|
132
|
+
.toLowerCase()
|
|
133
|
+
.includes('no such volume')) {
|
|
134
|
+
failed.push(full);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (error instanceof exec_1.Interrupted)
|
|
139
|
+
throw error; // Ctrl-C or a stopped job: unwind
|
|
140
|
+
failed.push(full);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return failed;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* One `docker stats --no-stream` sample for the given containers, as tab-separated
|
|
147
|
+
* `name<TAB>cpu%<TAB>mem-usage` lines ('' on error or none).
|
|
148
|
+
*
|
|
149
|
+
* Timed out: this is polled once a second by a sampler, so a wedged daemon would
|
|
150
|
+
* otherwise block it forever.
|
|
151
|
+
*/
|
|
152
|
+
async function dockerStats(containerIds) {
|
|
153
|
+
if (containerIds.length === 0)
|
|
154
|
+
return '';
|
|
155
|
+
try {
|
|
156
|
+
const result = await (0, docker_cli_1.docker)([
|
|
157
|
+
'stats',
|
|
158
|
+
'--no-stream',
|
|
159
|
+
'--format',
|
|
160
|
+
'{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}',
|
|
161
|
+
...containerIds,
|
|
162
|
+
], { capture: true, timeoutMs: 30000 });
|
|
163
|
+
return result.exitCode === 0 ? String(result.stdout ?? '') : '';
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Coarse state of the rocketchat service: running | exited | created | absent.
|
|
171
|
+
*
|
|
172
|
+
* One `docker compose ps` per call -- fine for a single repro. For listing many repros
|
|
173
|
+
* use `projectStates`, which is a single docker call for all of them.
|
|
174
|
+
*/
|
|
175
|
+
async function rcState(name) {
|
|
176
|
+
for (const line of (await engine.ps(name)).split('\n')) {
|
|
177
|
+
const parts = line.split('\t');
|
|
178
|
+
const service = parts[0];
|
|
179
|
+
// "rocketchat" for a normal repro, "rocketchat-1"/"-2"/… for a multi-instance one —
|
|
180
|
+
// the first instance found is enough for readiness.
|
|
181
|
+
if (service !== undefined && (service === 'rocketchat' || service.startsWith('rocketchat-'))) {
|
|
182
|
+
return parts[1] ?? 'unknown';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return 'absent';
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A compose `--format json` answer: one JSON document -- an object is one row, and anything
|
|
189
|
+
* else is handed back AS IT IS -- else NDJSON, one document per line. `null` when the whole
|
|
190
|
+
* answer is the JSON `null`: the listing then says the query failed, where wrapping it as
|
|
191
|
+
* `[null]` sent a null row to `item.Name` and crashed `list` (Go encodes a nil slice as
|
|
192
|
+
* `null`).
|
|
193
|
+
*
|
|
194
|
+
* EVERY ROW IS KEPT, whatever JSON it is, and `projectRows` reads each one as a mapping. This
|
|
195
|
+
* dropped the rows that were not objects, so an answer holding a stray one -- a WARN line on
|
|
196
|
+
* stdout, then the array, which the NDJSON reading takes as ONE row that is a list -- read as
|
|
197
|
+
* no projects at all: every workspace looked down, and `prune --yes` deleted one the listing
|
|
198
|
+
* called running. A row that is not a mapping throws there, before anything is pruned.
|
|
199
|
+
* Read with `loads` and stripped with `stripText`, as it always has been.
|
|
200
|
+
*/
|
|
201
|
+
function parseJsonOrNdjson(raw) {
|
|
202
|
+
const trimmed = (0, float_text_1.stripText)(raw);
|
|
203
|
+
if (trimmed === '')
|
|
204
|
+
return [];
|
|
205
|
+
const decodeFailed = (error) => error instanceof json_text_1.JsonSyntaxError || error instanceof SyntaxError;
|
|
206
|
+
try {
|
|
207
|
+
const document = (0, json_text_1.loads)(trimmed);
|
|
208
|
+
return isMapping(document) ? [document] : document;
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
if (!decodeFailed(error))
|
|
212
|
+
throw error;
|
|
213
|
+
// Newer compose emits a JSON array; older versions emit NDJSON, one object per
|
|
214
|
+
// line. Both are handled so callers work across compose versions.
|
|
215
|
+
const rows = [];
|
|
216
|
+
for (const line of (0, format_1.splitTextLines)(trimmed)) {
|
|
217
|
+
const stripped = (0, float_text_1.stripText)(line);
|
|
218
|
+
if (stripped === '')
|
|
219
|
+
continue;
|
|
220
|
+
try {
|
|
221
|
+
rows.push((0, json_text_1.loads)(stripped));
|
|
222
|
+
}
|
|
223
|
+
catch (lineError) {
|
|
224
|
+
if (!decodeFailed(lineError))
|
|
225
|
+
throw lineError;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return rows;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function isMapping(value) {
|
|
232
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Each row keyed by its `Name` (`""` when it has none), as far as that decides anything:
|
|
236
|
+
* the rows of what the listing returned (a string iterates by characters, and a number or
|
|
237
|
+
* a boolean is not iterable), each read as a mapping, and its name used as a key. The
|
|
238
|
+
* first row that is not a mapping throws `expected an object, got ...`, and a list or
|
|
239
|
+
* mapping for a name `... cannot be a key`, both TypeErrors; `runCli` reports either
|
|
240
|
+
* through the contract's last line, as it always has.
|
|
241
|
+
*/
|
|
242
|
+
function projectRows(data) {
|
|
243
|
+
let items;
|
|
244
|
+
if (typeof data === 'string')
|
|
245
|
+
items = [...data];
|
|
246
|
+
else if (Array.isArray(data))
|
|
247
|
+
items = data;
|
|
248
|
+
else
|
|
249
|
+
throw new TypeError((0, format_1.expectedText)('a list', data));
|
|
250
|
+
return items.map((item) => {
|
|
251
|
+
if (!isMapping(item)) {
|
|
252
|
+
throw new TypeError((0, format_1.expectedText)('an object', item));
|
|
253
|
+
}
|
|
254
|
+
const name = item.Name ?? '';
|
|
255
|
+
if (typeof name === 'object') {
|
|
256
|
+
throw new TypeError((0, format_1.keyRefusal)(name));
|
|
257
|
+
}
|
|
258
|
+
return [String(name), item];
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Parsed `docker compose ls --all --format json`, or null if the query failed.
|
|
263
|
+
*
|
|
264
|
+
* Bounded: the GUI polls this every 4 s on a worker. A daemon that answers `docker info`
|
|
265
|
+
* (so `dockerAvailable` says yes) but then wedges on `compose ls` would otherwise park a
|
|
266
|
+
* worker per poll. Failing to null is already the "could not ask docker" path.
|
|
267
|
+
*/
|
|
268
|
+
async function composeLs() {
|
|
269
|
+
try {
|
|
270
|
+
const result = await (0, docker_cli_1.docker)(['compose', 'ls', '--all', '--format', 'json'], {
|
|
271
|
+
capture: true,
|
|
272
|
+
timeoutMs: 30000,
|
|
273
|
+
});
|
|
274
|
+
if (result.exitCode !== 0)
|
|
275
|
+
return null;
|
|
276
|
+
return parseJsonOrNdjson(String(result.stdout ?? ''));
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (error instanceof exec_1.Interrupted)
|
|
280
|
+
throw error; // Ctrl-C or a stopped job: unwind
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Map compose project name -> status string for ALL projects, in one call.
|
|
286
|
+
*
|
|
287
|
+
* Status looks like "running(3)" / "exited(2)"; a fully `down`ed repro (no containers)
|
|
288
|
+
* is absent from the output. Returns null if the query itself failed -- callers that
|
|
289
|
+
* DELETE based on absence (prune) must not confuse "no projects" with "could not ask
|
|
290
|
+
* docker".
|
|
291
|
+
*/
|
|
292
|
+
async function projectStates() {
|
|
293
|
+
return await (0, docker_cli_1.cachedQuery)('project_states', async () => {
|
|
294
|
+
const data = await composeLs();
|
|
295
|
+
if (data === null)
|
|
296
|
+
return null;
|
|
297
|
+
const out = {};
|
|
298
|
+
for (const [name, item] of projectRows(data))
|
|
299
|
+
out[name] = String(item.Status ?? '');
|
|
300
|
+
return out;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Map compose project name -> its ConfigFiles string (comma-joined paths).
|
|
305
|
+
*
|
|
306
|
+
* Used to detect a project-name COLLISION: two repro workspaces (a real one and a
|
|
307
|
+
* throwaway in a different HOUSTON_HOME) derive the same project name `houston-<name>`,
|
|
308
|
+
* and `docker compose up` would then reconcile the wrong workspace's containers. null if
|
|
309
|
+
* docker could not be queried.
|
|
310
|
+
*/
|
|
311
|
+
async function projectConfigFiles() {
|
|
312
|
+
const data = await composeLs();
|
|
313
|
+
if (data === null)
|
|
314
|
+
return null;
|
|
315
|
+
const out = {};
|
|
316
|
+
for (const [name, item] of projectRows(data))
|
|
317
|
+
out[name] = String(item.ConfigFiles ?? '');
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* The MongoDB volume a Compose project left behind, [] for none; null if docker could not
|
|
322
|
+
* be asked. A project `down`ed without `--volumes` is absent from `compose ls`, and this is
|
|
323
|
+
* all of it that is left.
|
|
324
|
+
*/
|
|
325
|
+
async function projectDataVolumes(project) {
|
|
326
|
+
try {
|
|
327
|
+
const result = await (0, docker_cli_1.docker)([
|
|
328
|
+
'volume',
|
|
329
|
+
'ls',
|
|
330
|
+
'-q',
|
|
331
|
+
'--filter',
|
|
332
|
+
`label=com.docker.compose.project=${project}`,
|
|
333
|
+
'--filter',
|
|
334
|
+
'label=com.docker.compose.volume=mongodb_data',
|
|
335
|
+
], { capture: true, timeoutMs: 30000 });
|
|
336
|
+
if (result.exitCode !== 0)
|
|
337
|
+
return null;
|
|
338
|
+
return (0, format_1.splitTextLines)(String(result.stdout ?? '')).filter((line) => line.trim() !== '');
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
if (error instanceof exec_1.Interrupted)
|
|
342
|
+
throw error; // Ctrl-C or a stopped job: unwind
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* `serviceContainerIds` of `rocketchat`, else of `rocketchat-1`: ONE `docker compose ps -q`
|
|
348
|
+
* when the first answers. This asked the first twice -- once for the length, once for the
|
|
349
|
+
* value -- so every "still booting" tick of a readiness wait ran an extra docker process,
|
|
350
|
+
* about a hundred over a 300 s wait.
|
|
351
|
+
*/
|
|
352
|
+
async function rcContainerId(name) {
|
|
353
|
+
const first = await engine.serviceContainerIds(name, 'rocketchat');
|
|
354
|
+
const ids = first.length > 0 ? first : await engine.serviceContainerIds(name, 'rocketchat-1');
|
|
355
|
+
return ids[0];
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The RC container's ACTUAL environment, or null if it could not be read.
|
|
359
|
+
*
|
|
360
|
+
* The compose document is what a workspace was ASKED to run; this is what it IS
|
|
361
|
+
* running, and they diverge. MEASURED: an `env` apply interrupted mid-recreate left
|
|
362
|
+
* `OVERWRITE_SETTING_Accounts_RegistrationForm=Disabled` in both the compose file and
|
|
363
|
+
* `repro.json`, and absent from the container -- and neither `start`, `restart` nor a
|
|
364
|
+
* re-run `up` put it back, because none of them re-reads the compose config.
|
|
365
|
+
*
|
|
366
|
+
* NULL, NOT `{}`. "The container is not running" and "the container has no environment"
|
|
367
|
+
* are different facts, and the caller reports drift by comparing two sets -- so an empty
|
|
368
|
+
* one from a failed read would report every recorded variable as missing.
|
|
369
|
+
*/
|
|
370
|
+
async function rcContainerEnv(name) {
|
|
371
|
+
const id = await rcContainerId(name);
|
|
372
|
+
if (id === undefined)
|
|
373
|
+
return null;
|
|
374
|
+
let rows;
|
|
375
|
+
try {
|
|
376
|
+
const result = await (0, docker_cli_1.docker)(['inspect', '--format', '{{json .Config.Env}}', id], {
|
|
377
|
+
capture: true,
|
|
378
|
+
timeoutMs: 15000,
|
|
379
|
+
});
|
|
380
|
+
if (result.exitCode !== 0)
|
|
381
|
+
return null;
|
|
382
|
+
rows = JSON.parse(String(result.stdout ?? 'null'));
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
if (error instanceof exec_1.Interrupted)
|
|
386
|
+
throw error; // Ctrl-C or a stopped job: unwind
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
if (!Array.isArray(rows))
|
|
390
|
+
return null;
|
|
391
|
+
const out = {};
|
|
392
|
+
for (const row of rows) {
|
|
393
|
+
const text = String(row);
|
|
394
|
+
const at = text.indexOf('=');
|
|
395
|
+
// An item set on a mapping (`setItemChecked`): a container running `__proto__=x` has that
|
|
396
|
+
// variable. Assigned, it was dropped, and `houston env` reported the override it had
|
|
397
|
+
// just applied as NOT RUNNING.
|
|
398
|
+
if (at > 0)
|
|
399
|
+
(0, format_1.setItemChecked)(out, text.slice(0, at), text.slice(at + 1));
|
|
400
|
+
}
|
|
401
|
+
return out;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* The running containers that have no network at all.
|
|
405
|
+
*
|
|
406
|
+
* A start that fails at its port binding leaves the container attached to nothing, and the
|
|
407
|
+
* next `compose start` "succeeds" with it so: Rocket.Chat up with only `lo`, no published
|
|
408
|
+
* port, and `getaddrinfo EAI_AGAIN mongodb`. Nothing short of recreating it gives it back.
|
|
409
|
+
*/
|
|
410
|
+
async function networklessContainers(name) {
|
|
411
|
+
try {
|
|
412
|
+
const listed = await engine.compose(name, ['ps', '-q'], { capture: true });
|
|
413
|
+
const ids = String(listed.stdout ?? '')
|
|
414
|
+
.split('\n')
|
|
415
|
+
.map((line) => line.trim())
|
|
416
|
+
.filter((line) => line !== '');
|
|
417
|
+
if (listed.exitCode !== 0 || ids.length === 0)
|
|
418
|
+
return [];
|
|
419
|
+
const result = await (0, docker_cli_1.docker)(['inspect', '--format', '{{.Name}}\t{{len .NetworkSettings.Networks}}', ...ids], { capture: true, timeoutMs: 15000 });
|
|
420
|
+
if (result.exitCode !== 0)
|
|
421
|
+
return [];
|
|
422
|
+
return String(result.stdout ?? '')
|
|
423
|
+
.split('\n')
|
|
424
|
+
.map((line) => line.split('\t'))
|
|
425
|
+
.filter(([, count]) => (count ?? '').trim() === '0')
|
|
426
|
+
.map(([container]) => (container ?? '').replace(/^\//u, ''));
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (error instanceof exec_1.Interrupted)
|
|
430
|
+
throw error;
|
|
431
|
+
return [];
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* What Docker recorded as each container's start error, `service: error`, for those that
|
|
436
|
+
* have one.
|
|
437
|
+
*
|
|
438
|
+
* `compose start` prints the reason (a port somebody else holds) on its own output and
|
|
439
|
+
* exits 1. In the GUI that went to serve's terminal, and the job said only "`docker compose
|
|
440
|
+
* start` failed" -- a port clash and a broken image read the same. Docker keeps the reason
|
|
441
|
+
* on the container, so it is asked afterwards rather than parsed out of the stream.
|
|
442
|
+
*/
|
|
443
|
+
async function startErrors(name) {
|
|
444
|
+
try {
|
|
445
|
+
const listed = await engine.compose(name, ['ps', '--all', '-q'], { capture: true });
|
|
446
|
+
const ids = String(listed.stdout ?? '')
|
|
447
|
+
.split('\n')
|
|
448
|
+
.map((line) => line.trim())
|
|
449
|
+
.filter((line) => line !== '');
|
|
450
|
+
if (listed.exitCode !== 0 || ids.length === 0)
|
|
451
|
+
return [];
|
|
452
|
+
const result = await (0, docker_cli_1.docker)([
|
|
453
|
+
'inspect',
|
|
454
|
+
'--format',
|
|
455
|
+
'{{index .Config.Labels "com.docker.compose.service"}}\t{{.State.Error}}',
|
|
456
|
+
...ids,
|
|
457
|
+
], { capture: true, timeoutMs: 15000 });
|
|
458
|
+
if (result.exitCode !== 0)
|
|
459
|
+
return [];
|
|
460
|
+
return String(result.stdout ?? '')
|
|
461
|
+
.split('\n')
|
|
462
|
+
.map((line) => line.split('\t'))
|
|
463
|
+
.filter(([, error]) => (error ?? '').trim() !== '')
|
|
464
|
+
.map(([service, error]) => `${service ?? '?'}: ${(error ?? '').trim()}`);
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
if (error instanceof exec_1.Interrupted)
|
|
468
|
+
throw error;
|
|
469
|
+
return [];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* The workspace's one-shot setup containers -- `mongo-init`, `minio-init` -- as they stand.
|
|
474
|
+
*
|
|
475
|
+
* By name and by policy: a `-init` service with no restart policy runs once and exits. An
|
|
476
|
+
* unreadable answer is none, so a box that cannot be asked waits for nothing extra.
|
|
477
|
+
*/
|
|
478
|
+
async function oneShotSetups(name) {
|
|
479
|
+
try {
|
|
480
|
+
const listed = await engine.compose(name, ['ps', '--all', '-q'], { capture: true });
|
|
481
|
+
const ids = String(listed.stdout ?? '')
|
|
482
|
+
.split('\n')
|
|
483
|
+
.map((line) => line.trim())
|
|
484
|
+
.filter((line) => line !== '');
|
|
485
|
+
if (listed.exitCode !== 0 || ids.length === 0)
|
|
486
|
+
return [];
|
|
487
|
+
const result = await (0, docker_cli_1.docker)([
|
|
488
|
+
'inspect',
|
|
489
|
+
'--format',
|
|
490
|
+
'{{index .Config.Labels "com.docker.compose.service"}}\t' +
|
|
491
|
+
'{{.HostConfig.RestartPolicy.Name}}\t{{.State.Status}}\t{{.State.ExitCode}}',
|
|
492
|
+
...ids,
|
|
493
|
+
], { capture: true, timeoutMs: 15000 });
|
|
494
|
+
if (result.exitCode !== 0)
|
|
495
|
+
return [];
|
|
496
|
+
return String(result.stdout ?? '')
|
|
497
|
+
.split('\n')
|
|
498
|
+
.map((line) => line.trim().split('\t'))
|
|
499
|
+
.filter(([service, policy]) => (service ?? '').endsWith('-init') && ['no', ''].includes(policy ?? ''))
|
|
500
|
+
.map(([service, , status, code]) => ({
|
|
501
|
+
service: service ?? '',
|
|
502
|
+
status: status ?? '',
|
|
503
|
+
exitCode: Number(code) || 0,
|
|
504
|
+
}));
|
|
505
|
+
}
|
|
506
|
+
catch (error) {
|
|
507
|
+
if (error instanceof exec_1.Interrupted)
|
|
508
|
+
throw error;
|
|
509
|
+
return [];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* How many times the repro's rocketchat container has restarted -- a nonzero and
|
|
514
|
+
* climbing value signals a crash-loop, usually resource pressure. 0 if unknown.
|
|
515
|
+
*/
|
|
516
|
+
async function rcRestartCount(name) {
|
|
517
|
+
const id = await rcContainerId(name);
|
|
518
|
+
if (id === undefined)
|
|
519
|
+
return 0;
|
|
520
|
+
try {
|
|
521
|
+
// Bounded for the same reason as composeLs: the detail panel refreshes this on a
|
|
522
|
+
// timer, and "unknown" (0) is already the documented fallback.
|
|
523
|
+
const result = await (0, docker_cli_1.docker)(['inspect', '--format', '{{.RestartCount}}', id], {
|
|
524
|
+
capture: true,
|
|
525
|
+
timeoutMs: 15000,
|
|
526
|
+
});
|
|
527
|
+
const count = Number.parseInt(String(result.stdout ?? '0').trim(), 10);
|
|
528
|
+
return Number.isFinite(count) ? count : 0;
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
// Any failure to run or read the command, which an Interrupted is not: a
|
|
532
|
+
// Ctrl-C in `docker inspect` during `backup`'s wait for Rocket.Chat was a restart count
|
|
533
|
+
// of 0, one more `still booting` line, and the next wait ending the run.
|
|
534
|
+
if (error instanceof exec_1.Interrupted)
|
|
535
|
+
throw error;
|
|
536
|
+
return 0;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Map compose project -> {service: `Status` string} for EVERY container.
|
|
541
|
+
*
|
|
542
|
+
* The same single `docker ps`; it just stopped discarding the rest of the output.
|
|
543
|
+
* `rcStatusByProject` used to keep the rocketchat line and throw the others away, which
|
|
544
|
+
* is why a repro whose MONGODB had exited reported `running` and `healthy` -- both
|
|
545
|
+
* derived from the Rocket.Chat container alone, and Rocket.Chat serves /api/info
|
|
546
|
+
* perfectly well with no database behind it.
|
|
547
|
+
*/
|
|
548
|
+
async function servicesByProject() {
|
|
549
|
+
return await (0, docker_cli_1.cachedQuery)('services_by_project', servicesByProjectUncached);
|
|
550
|
+
}
|
|
551
|
+
async function servicesByProjectUncached() {
|
|
552
|
+
let stdout;
|
|
553
|
+
try {
|
|
554
|
+
const result = await (0, docker_cli_1.docker)([
|
|
555
|
+
'ps',
|
|
556
|
+
'--all',
|
|
557
|
+
'--format',
|
|
558
|
+
'{{.Label "com.docker.compose.project"}}\t{{.Label "com.docker.compose.service"}}\t{{.Status}}',
|
|
559
|
+
], { capture: true, timeoutMs: 30000 });
|
|
560
|
+
// Same 4 s poll bound as composeLs; {} = "could not ask".
|
|
561
|
+
if (result.exitCode !== 0)
|
|
562
|
+
return {};
|
|
563
|
+
stdout = String(result.stdout ?? '');
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
if (error instanceof exec_1.Interrupted)
|
|
567
|
+
throw error; // Ctrl-C or a stopped job: unwind
|
|
568
|
+
return {};
|
|
569
|
+
}
|
|
570
|
+
const out = {};
|
|
571
|
+
for (const line of stdout.split('\n')) {
|
|
572
|
+
const parts = line.split('\t');
|
|
573
|
+
const [project, service, status] = parts;
|
|
574
|
+
if (parts.length < 3 || project === undefined || project === '')
|
|
575
|
+
continue;
|
|
576
|
+
out[project] ?? (out[project] = {});
|
|
577
|
+
out[project][service ?? ''] = status ?? '';
|
|
578
|
+
}
|
|
579
|
+
return out;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Map compose project -> its rocketchat container `Status` string ("Up 2 hours
|
|
583
|
+
* (healthy)"), in ONE `docker ps` call. Used to show uptime and health per repro without
|
|
584
|
+
* an N-call fan-out.
|
|
585
|
+
*/
|
|
586
|
+
async function rcStatusByProject(byProject) {
|
|
587
|
+
const servicesByName = byProject ?? (await servicesByProject());
|
|
588
|
+
const out = {};
|
|
589
|
+
for (const [project, services] of Object.entries(servicesByName)) {
|
|
590
|
+
out[project] = services.rocketchat ?? services['rocketchat-1'] ?? '';
|
|
591
|
+
}
|
|
592
|
+
return out;
|
|
593
|
+
}
|
|
594
|
+
/** Per-container `{service, state, status, health}` for a repro, including stopped. */
|
|
595
|
+
async function containerDetails(name) {
|
|
596
|
+
const result = await engine.compose(name, ['ps', '--all', '--format', 'json'], {
|
|
597
|
+
capture: true,
|
|
598
|
+
});
|
|
599
|
+
if (result.exitCode !== 0)
|
|
600
|
+
return [];
|
|
601
|
+
// The object rows only, as before `parseJsonOrNdjson` kept every row: the previous
|
|
602
|
+
// implementation reads each row as a mapping here too, but nothing has measured what a
|
|
603
|
+
// detail panel should do on the non-object answer compose never gives, so this reads it
|
|
604
|
+
// as it did.
|
|
605
|
+
const data = parseJsonOrNdjson(String(result.stdout ?? ''));
|
|
606
|
+
return (Array.isArray(data) ? data.filter(isMapping) : []).map((item) => ({
|
|
607
|
+
service: String(item.Service ?? ''),
|
|
608
|
+
state: String(item.State ?? ''),
|
|
609
|
+
status: String(item.Status ?? ''),
|
|
610
|
+
health: String(item.Health ?? ''),
|
|
611
|
+
}));
|
|
612
|
+
}
|