feat: add hwpod node native websocket dispatch
This commit is contained in:
+15
-17
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bun
|
||||
import { createCloudApiServer } from "../../internal/cloud/server.ts";
|
||||
import { createCloudApiBunServer } from "../../internal/cloud/bun-server.ts";
|
||||
import { applyCloudApiImageEnv, parsePort, parseTimeout } from "./runtime-options.ts";
|
||||
|
||||
const host = process.env.HWLAB_CLOUD_API_HOST || "0.0.0.0";
|
||||
@@ -14,28 +14,26 @@ const codeAgentHardTimeoutMs = parseTimeout(process.env.HWLAB_CODE_AGENT_HARD_TI
|
||||
});
|
||||
applyCloudApiImageEnv(process.env);
|
||||
|
||||
const server = createCloudApiServer({
|
||||
const runtime = await createCloudApiBunServer({
|
||||
host,
|
||||
port,
|
||||
codeAgentTimeoutMs,
|
||||
codeAgentHardTimeoutMs
|
||||
});
|
||||
|
||||
server.listen(port, host, () => {
|
||||
const address = server.address();
|
||||
const resolvedPort = typeof address === "object" && address ? address.port : port;
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
serviceId: "hwlab-cloud-api",
|
||||
status: "listening",
|
||||
host,
|
||||
port: resolvedPort
|
||||
})}\n`
|
||||
);
|
||||
});
|
||||
process.stdout.write(
|
||||
`${JSON.stringify({
|
||||
serviceId: "hwlab-cloud-api",
|
||||
status: "listening",
|
||||
host,
|
||||
port: runtime.port,
|
||||
hwpodNodeWs: "/v1/hwpod-node/ws"
|
||||
})}\n`
|
||||
);
|
||||
|
||||
for (const signal of ["SIGINT", "SIGTERM"]) {
|
||||
process.on(signal, () => {
|
||||
server.close(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
runtime.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user