feat: 将 Workbench 后端改造为 Temporal native 架构

This commit is contained in:
root
2026-07-17 08:02:32 +02:00
parent 91fbb78291
commit 2354fc8dd2
30 changed files with 1157 additions and 21 deletions
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bun
import { createWorkbenchHttpApp } from "../../internal/workbench/http.ts";
import { workbenchRuntime } from "../../internal/workbench/runtime.ts";
const runtime = workbenchRuntime();
const app = createWorkbenchHttpApp({ dispatch: runtime.dispatch, snapshot: runtime.application.snapshot?.bind(runtime.application), authorization: process.env.WORKBENCH_API_AUTHORIZATION, close: runtime.close });
const host = process.env.WORKBENCH_API_HOST || "0.0.0.0";
const port = positivePort(process.env.WORKBENCH_API_PORT || process.env.PORT, 6677);
const server = Bun.serve({ hostname: host, port, fetch: (request) => app.fetch(request) });
process.stdout.write(`${JSON.stringify({ serviceId: "hwlab-workbench-api", status: "listening", mode: runtime.mode, host, port: server.port, temporalNamespace: runtime.temporalNamespace, taskQueue: runtime.taskQueue })}\n`);
for (const signal of ["SIGINT", "SIGTERM"] as const) process.once(signal, async () => { server.stop(true); await app.close(); process.exit(0); });
function positivePort(value: string | undefined, fallback: number) { const parsed = Number.parseInt(String(value ?? fallback), 10); if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) throw new Error("WORKBENCH_API_PORT must be a valid port"); return parsed; }