forked from mtusi2026/mtusi2026lab7
27 lines
950 B
TypeScript
27 lines
950 B
TypeScript
import { run, requireThat } from "./runtime";
|
|
import { containerID } from "./runtime-inspect";
|
|
const gateways = [
|
|
"lb",
|
|
"api1-gateway",
|
|
"api2-gateway",
|
|
"worker-gateway",
|
|
"broker-gateway",
|
|
"s3-gateway",
|
|
"collector-gateway",
|
|
"openobserve-gateway",
|
|
"grafana-gateway",
|
|
];
|
|
export async function reloadGateway(service: string) {
|
|
requireThat(gateways.includes(service), "INVALID_GATEWAY_TARGET");
|
|
const id = await containerID(service);
|
|
const state = JSON.parse((await run(["docker", "inspect", id])).out)[0];
|
|
requireThat(
|
|
state.Config.Labels["com.docker.compose.project"] ===
|
|
"mtuci-vp7-security" && state.State.Running === true,
|
|
"GATEWAY_NOT_OWNED_RUNNING",
|
|
);
|
|
// Native HAProxy master-worker reload preserves the network namespace used by sidecars.
|
|
// hard-stop-after2s drains old TLS connections so revoked clients cannot keep a pool alive forever.
|
|
await run(["docker", "kill", "--signal", "USR2", id]);
|
|
}
|