Add persistent HTTP server to background service daemon
This commit is contained in:
1 parent
13ed555bbb
commit
f183cc8294
7 files changed
+237
-50
No files matched your search
+15
-1
@@ -78,9 +78,23 @@ const KNOWN_AREAS = new Set([
|
||||
|
||||
export type { CliResult, CliRunOptions } from "./types.js";
|
||||
|
||||
const STANDING_COMMANDS = new Set(["http", "server", "web", "mcp"]);
|
||||
|
||||
function isStandingCommand(argv: string[]): boolean {
|
||||
if (!argv.length) return false;
|
||||
const first = argv[0]?.toLowerCase();
|
||||
const second = argv[1]?.toLowerCase();
|
||||
if (first && STANDING_COMMANDS.has(first)) return true;
|
||||
if ((first === "service" || first === "daemon") && second === "run") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
let runQueue = Promise.resolve();
|
||||
|
||||
export function runCli(argv: string[], options: CliRunOptions = {}): Promise<CliResult> {
|
||||
if (isStandingCommand(argv)) {
|
||||
return runCliOnce(argv, options);
|
||||
}
|
||||
const run = runQueue.then(() => runCliOnce(argv, options));
|
||||
runQueue = run.then(
|
||||
() => undefined,
|
||||
@@ -194,7 +208,7 @@ async function dispatch(argv: string[], runtime: CliRuntime) {
|
||||
}
|
||||
|
||||
if (area === "service") {
|
||||
await handleServiceCommand(action, runtime);
|
||||
await handleServiceCommand(action, runtime, args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user