Files
hose-use/src/cli/commands/http.ts
T
gitea c1dc9f1616
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
feat: release v0.5.0 with embedded HTTP server and resident daemon service
2026-09-03 15:19:12 +08:00

29 lines
814 B
TypeScript

import { startHttpServer } from "../../http/server.js";
import { numberOption, stringOption } from "../parser.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../types.js";
export async function handleHttpCommand(
parsed: CliParsedArgs,
runtime: CliRuntime
): Promise<CliResult> {
const port = numberOption(parsed.options, ["port", "p"]);
const host = stringOption(parsed.options, ["host", "h"]);
const server = await startHttpServer({ port, host, silent: runtime.jsonMode });
// Handle graceful shutdown
const shutdown = () => {
server.close(() => {
process.exit(0);
});
};
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
// Keep alive in foreground
await new Promise<void>(() => {});
return { stdout: "", stderr: "", exitCode: 0 };
}