3 files changed
+10
-19
No files matched your search
@@ -15,10 +15,6 @@ function containerName(slug: string) {
|
||||
return `nextchair-${slug}`;
|
||||
}
|
||||
|
||||
function healthState(value: string | undefined): BusinessStatus["health"] {
|
||||
return value === "healthy" || value === "unhealthy" || value === "starting" ? value : "unknown";
|
||||
}
|
||||
|
||||
async function readRegistry(): Promise<BusinessDeployment[]> {
|
||||
try {
|
||||
return JSON.parse(await fs.readFile(registryPath(), "utf8")) as BusinessDeployment[];
|
||||
@@ -40,7 +36,7 @@ async function inspectContainer(slug: string) {
|
||||
try {
|
||||
const result = await docker(["inspect", "-f", "{{.State.Status}}|{{if .State.Health}}{{.State.Health.Status}}{{end}}", containerName(slug)]);
|
||||
const [container, health] = result.stdout.trim().split("|");
|
||||
return { container: container === "running" ? "running" : container ? "stopped" : "unknown", health: healthState(health) } as const;
|
||||
return { container: container === "running" ? "running" : container ? "stopped" : "unknown", health: health || "unknown" } as const;
|
||||
} catch {
|
||||
return { container: "unknown", health: "unknown" } as const;
|
||||
}
|
||||
@@ -58,13 +54,8 @@ async function databaseStatus() {
|
||||
async function storageBytes(slug: string) {
|
||||
try {
|
||||
const volume = await docker(["volume", "inspect", "-f", "{{.Mountpoint}}", `nextchair-media-${slug}`]);
|
||||
const mountpoint = volume.stdout.trim();
|
||||
if (!mountpoint) return null;
|
||||
const usage = await run("du", ["-sk", mountpoint], { maxBuffer: 1024 * 64 });
|
||||
const kilobytes = usage.stdout.trim().split(/\s+/)[0];
|
||||
if (!kilobytes) return null;
|
||||
const bytes = Number.parseInt(kilobytes, 10) * 1024;
|
||||
return Number.isFinite(bytes) ? bytes : null;
|
||||
const usage = await run("du", ["-sk", volume.stdout.trim()], { maxBuffer: 1024 * 64 });
|
||||
return Number.parseInt(usage.stdout.trim().split(/\s+/)[0], 10) * 1024;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user