24 lines
753 B
TypeScript
24 lines
753 B
TypeScript
import { createCanaryGateway } from './canary-gateway.js';
|
|
import { readCanaryRuntimeOptions } from './canary-runtime.js';
|
|
|
|
const gateway = createCanaryGateway(readCanaryRuntimeOptions(process.env));
|
|
|
|
let stopping = false;
|
|
async function stop(signal: string): Promise<void> {
|
|
if (stopping) return;
|
|
stopping = true;
|
|
process.stdout.write(`Stopping canary gateway (${signal})\n`);
|
|
await gateway.stop();
|
|
}
|
|
|
|
process.once('SIGINT', () => void stop('SIGINT'));
|
|
process.once('SIGTERM', () => void stop('SIGTERM'));
|
|
|
|
try {
|
|
await gateway.start();
|
|
process.stdout.write(`Canary gateway listening at ${gateway.origin}\n`);
|
|
} catch (error) {
|
|
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
process.exitCode = 1;
|
|
}
|