13 lines
830 B
TypeScript
Executable File
13 lines
830 B
TypeScript
Executable File
#!/usr/bin/env bun
|
|
import { createHarnessRLHttpApp } from "../../internal/harnessrl/http.ts";
|
|
import { harnessRLRuntime } from "../../internal/harnessrl/runtime.ts";
|
|
|
|
const runtime = harnessRLRuntime();
|
|
await runtime.registry.ensureSchema();
|
|
const app = createHarnessRLHttpApp({ service: runtime.service });
|
|
const host = process.env.HARNESSRL_API_HOST || "0.0.0.0";
|
|
const port = Number.parseInt(process.env.HARNESSRL_API_PORT || process.env.PORT || "6675", 10);
|
|
const server = Bun.serve({ hostname: host, port, fetch: (request) => app.fetch(request) });
|
|
process.stdout.write(`${JSON.stringify({ serviceId: "hwlab-harnessrl-api", status: "listening", host, port: server.port })}\n`);
|
|
for (const signal of ["SIGINT", "SIGTERM"] as const) process.once(signal, async () => { server.stop(true); await app.close(); process.exit(0); });
|