feat(release): add reversible production cutover gates

This commit is contained in:
chick
2026-07-18 17:24:51 +08:00
parent 3718c91706
commit 4a7e29cf06
18 changed files with 1468 additions and 8 deletions
+15
View File
@@ -10,8 +10,11 @@ export interface CanaryRuntimeEnvironment {
readonly CANARY_PORT?: string;
readonly CANARY_UPSTREAM_PORT?: string;
readonly MULTI_SIMADMIN_GATEWAY_TOKEN?: string;
readonly MULTI_SIMADMIN_CUTOVER_ACK?: string;
}
export const PRODUCTION_CUTOVER_ACK = 'I ACKNOWLEDGE MULTI-SIMADMIN OWNS PORT 8788';
function environmentPort(value: string | undefined, name: string, fallback: number): number {
if (value === undefined || value === '') return fallback;
const port = Number(value);
@@ -41,3 +44,15 @@ export function readCanaryRuntimeOptions(
gatewayToken,
});
}
export function readProductionGatewayRuntimeOptions(
environment: CanaryRuntimeEnvironment,
): CanaryGatewayOptions {
if (environment.MULTI_SIMADMIN_CUTOVER_ACK !== PRODUCTION_CUTOVER_ACK) {
throw new Error(
`Production gateway requires MULTI_SIMADMIN_CUTOVER_ACK=${PRODUCTION_CUTOVER_ACK}`,
);
}
const options = readCanaryRuntimeOptions({ ...environment, CANARY_PORT: '8788' });
return Object.freeze({ ...options, ownsProductionPort: true });
}