feat: add cloud api skeleton
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
import { createCloudApiServer } from "../../internal/cloud/server.mjs";
|
||||
|
||||
const host = process.env.HWLAB_CLOUD_API_HOST || "0.0.0.0";
|
||||
const port = Number.parseInt(process.env.HWLAB_CLOUD_API_PORT || process.env.PORT || "6667", 10);
|
||||
|
||||
const server = createCloudApiServer();
|
||||
|
||||
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`
|
||||
);
|
||||
});
|
||||
|
||||
for (const signal of ["SIGINT", "SIGTERM"]) {
|
||||
process.on(signal, () => {
|
||||
server.close(() => {
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user