feat: add auto-start server feature for CLI

- Added /health endpoint to server for readiness checks (no auth required)
- Created autoStartServer module that auto-starts server when:
  - HAPI_SERVER_URL not set (using default localhost:3006)
  - cliApiToken exists in settings (server previously used)
  - Port 3006 is not currently listening
- Server runs as child process (not daemon) and exits when CLI exits
- Integrated maybeAutoStartServer() into hapi, codex, and gemini commands
This commit is contained in:
weishu
2026-01-02 16:21:14 +08:00
parent 11c95126e3
commit 94823b7a8b
3 changed files with 172 additions and 0 deletions
+3
View File
@@ -61,6 +61,9 @@ function createWebApp(options: {
app.use('*', logger())
// Health check endpoint (no auth required)
app.get('/health', (c) => c.json({ status: 'ok' }))
const corsOrigins = configuration.corsOrigins
const corsOriginOption = corsOrigins.includes('*') ? '*' : corsOrigins
const corsMiddleware = cors({