ai-agent-router 0.1.21 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/fallback-build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/config/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/[...path]/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/models/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/apply/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/available-models/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/save/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/status/route.js.nft.json +1 -1
- package/.next/server/app/api/ide/claude/test/route.js.nft.json +1 -1
- package/.next/server/app/api/logs/route.js.nft.json +1 -1
- package/.next/server/app/api/models/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/.next/server/app/api/providers/test/route.js.nft.json +1 -1
- package/.next/server/app/api/service/force-stop/route.js.nft.json +1 -1
- package/.next/server/app/api/service/start/route.js.nft.json +1 -1
- package/.next/server/app/api/service/status/route.js.nft.json +1 -1
- package/.next/server/app/api/service/stop/route.js.nft.json +1 -1
- package/.next/server/app/ide.html +1 -1
- package/.next/server/app/ide.rsc +1 -1
- package/.next/server/app/ide.segments/_full.segment.rsc +1 -1
- package/.next/server/app/ide.segments/_head.segment.rsc +1 -1
- package/.next/server/app/ide.segments/_index.segment.rsc +1 -1
- package/.next/server/app/ide.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/ide.segments/ide/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/ide.segments/ide.segment.rsc +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/logs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/logs.html +1 -1
- package/.next/server/app/logs.rsc +2 -2
- package/.next/server/app/logs.segments/_full.segment.rsc +2 -2
- package/.next/server/app/logs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/logs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/logs.segments/logs/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/logs.segments/logs.segment.rsc +1 -1
- package/.next/server/app/models.html +1 -1
- package/.next/server/app/models.rsc +1 -1
- package/.next/server/app/models.segments/_full.segment.rsc +1 -1
- package/.next/server/app/models.segments/_head.segment.rsc +1 -1
- package/.next/server/app/models.segments/_index.segment.rsc +1 -1
- package/.next/server/app/models.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/models.segments/models/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/models.segments/models.segment.rsc +1 -1
- package/.next/server/app/providers.html +1 -1
- package/.next/server/app/providers.rsc +1 -1
- package/.next/server/app/providers.segments/_full.segment.rsc +1 -1
- package/.next/server/app/providers.segments/_head.segment.rsc +1 -1
- package/.next/server/app/providers.segments/_index.segment.rsc +1 -1
- package/.next/server/app/providers.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/providers.segments/providers/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/providers.segments/providers.segment.rsc +1 -1
- package/.next/server/chunks/[root-of-the-server]__1480f018._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1480f018._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__1909f3aa._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1909f3aa._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__1d4b7fc5._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1d4b7fc5._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__372ef2bf._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__372ef2bf._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__3aaf963c._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__3aaf963c._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__6ce199d2._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__6ce199d2._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__772134c6._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__772134c6._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__7b77f523._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__7b77f523._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js +18 -18
- package/.next/server/chunks/[root-of-the-server]__c1b4b601._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__ccfc7f1d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__ccfc7f1d._.js.map +1 -1
- package/.next/server/chunks/ssr/src_app_logs_page_tsx_7b7b7b83._.js +1 -1
- package/.next/server/chunks/ssr/src_app_logs_page_tsx_7b7b7b83._.js.map +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/static/chunks/{81c904164fe81379.js → b6b258e8582e47c4.js} +1 -1
- package/README.md +100 -111
- package/dist/src/app/api/gateway/[...path]/route.js +1 -1
- package/dist/src/app/api/gateway/route.js +1 -1
- package/dist/src/app/api/logs/route.js +2 -2
- package/dist/src/app/api/models/route.js +5 -5
- package/dist/src/app/api/providers/route.js +4 -4
- package/dist/src/app/api/providers/test/route.js +1 -1
- package/dist/src/app/api/service/start/route.js +1 -1
- package/dist/src/app/api/service/status/route.js +1 -1
- package/dist/src/app/api/service/stop/route.js +1 -1
- package/dist/src/app/logs/page.js +13 -1
- package/dist/src/cli/index.js +218 -20
- package/dist/src/db/database.js +35 -1
- package/dist/src/db/queries.js +6 -6
- package/dist/src/server/logger.js +22 -4
- package/package.json +2 -1
- package/src/app/api/gateway/[...path]/route.ts +1 -1
- package/src/app/api/gateway/route.ts +1 -1
- package/src/app/api/logs/route.ts +2 -2
- package/src/app/api/models/route.ts +5 -5
- package/src/app/api/providers/route.ts +4 -4
- package/src/app/api/providers/test/route.ts +1 -1
- package/src/app/api/service/start/route.ts +1 -1
- package/src/app/api/service/status/route.ts +1 -1
- package/src/app/api/service/stop/route.ts +1 -1
- package/src/app/logs/page.tsx +15 -5
- package/src/cli/index.ts +228 -25
- package/src/db/database.ts +34 -4
- package/src/db/queries.ts +6 -6
- package/src/server/logger.ts +19 -4
- /package/.next/static/{PkfqdzwOZgX-UhSNUuhdp → ryTeHAYUvjT1bYolc-x9Z}/_buildManifest.js +0 -0
- /package/.next/static/{PkfqdzwOZgX-UhSNUuhdp → ryTeHAYUvjT1bYolc-x9Z}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{PkfqdzwOZgX-UhSNUuhdp → ryTeHAYUvjT1bYolc-x9Z}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/service-manager.ts","../../../src/app/api/service/start/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n","import { NextRequest, NextResponse } from 'next/server';\nimport { getDatabase } from '@/db/database';\nimport { serviceManager } from '@/server/service-manager';\nimport { getConfig } from '@/db/queries';\nimport net from 'net';\n\n// Ensure Node.js runtime (required for service manager)\nexport const runtime = 'nodejs';\n\nexport async function POST(request: NextRequest) {\n try {\n // Initialize database\n getDatabase();\n \n const body = await request.json().catch(() => ({}));\n const port = body.port ? parseInt(body.port, 10) : null;\n\n // Get port from config if not provided\n let targetPort = port;\n if (!targetPort) {\n const portConfig = await getConfig('port');\n targetPort = portConfig ? parseInt(portConfig.value, 10) : 3000;\n }\n\n // In development, if port is 3000 (default dev server port), check for conflict\n const isDev = process.env.NODE_ENV !== 'production';\n if (isDev && targetPort === 3000) {\n // Check if port 3000 is in use (likely by the dev server)\n const testServer = net.createServer();\n const portInUse = await new Promise<boolean>((resolve) => {\n testServer.listen(3000, () => {\n testServer.close(() => resolve(false));\n });\n testServer.on('error', () => resolve(true));\n setTimeout(() => {\n testServer.close(() => resolve(false));\n }, 100);\n });\n\n if (portInUse) {\n return NextResponse.json(\n { \n status: 'stopped', \n error: 'Port 3000 is already in use by the development server. Please configure a different port (e.g., 3001) in the settings above.' \n },\n { status: 400 }\n );\n }\n }\n\n // Validate port\n if (isNaN(targetPort) || targetPort < 1 || targetPort > 65535) {\n return NextResponse.json(\n { status: 'stopped', error: 'Invalid port number' },\n { status: 400 }\n );\n }\n\n const result = await serviceManager.start(targetPort);\n \n if (result.error) {\n return NextResponse.json(result, { status: 400 });\n }\n\n return NextResponse.json(result);\n } catch (error: any) {\n console.error('Service start API error:', error);\n return NextResponse.json(\n { status: 'stopped', error: error.message || 'Failed to start service' },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/service/start/route\",\n pathname: \"/api/service/start\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/service/start/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/service/start/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAM,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,EAAA,IAAI,EAsXnB,EAAiB,IA5W9B,AA4WkC,MA5W5B,AACI,eAAsC,IAAK,CAC3C,YAAsB,CAAM,AAKpC,OAAc,mBAAmB,CAAW,CAAoB,CAC9D,GAAI,CAEF,OADA,MAAM,EAAU,CAAC,MAAM,EAAE,EAAI,QAAQ,CAAC,GAC/B,CACT,CAAE,KAAM,CACN,OAAO,CACT,CACF,CAKA,MAAc,mBAAmB,CAAY,CAAoB,CAC/D,OAAO,IAAI,QAAQ,AAAC,IAClB,IAAM,EAAS,EAAA,OAAG,CAAC,YAAY,GAE/B,EAAO,MAAM,CAAC,EAAM,KAClB,EAAO,IAAI,CAAC,QAAS,IAAM,GAAQ,IACnC,EAAO,KAAK,EACd,GAEA,EAAO,EAAE,CAAC,QAAS,KACjB,GAAQ,EACV,EACF,EACF,CAKA,MAAc,aAAa,CAAY,CAA0B,CAC/D,GAAI,CAEF,GAAM,CAAE,QAAM,CAAE,CAA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Q,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GACvB,AAD0B,CAE9B,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[2]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/service-manager.ts","../../../src/app/api/service/start/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n","import { NextRequest, NextResponse } from 'next/server';\nimport { getDatabase } from '@/db/database';\nimport { serviceManager } from '@/server/service-manager';\nimport { getConfig } from '@/db/queries';\nimport net from 'net';\n\n// Ensure Node.js runtime (required for service manager)\nexport const runtime = 'nodejs';\n\nexport async function POST(request: NextRequest) {\n try {\n // Initialize database\n await getDatabase();\n \n const body = await request.json().catch(() => ({}));\n const port = body.port ? parseInt(body.port, 10) : null;\n\n // Get port from config if not provided\n let targetPort = port;\n if (!targetPort) {\n const portConfig = await getConfig('port');\n targetPort = portConfig ? parseInt(portConfig.value, 10) : 3000;\n }\n\n // In development, if port is 3000 (default dev server port), check for conflict\n const isDev = process.env.NODE_ENV !== 'production';\n if (isDev && targetPort === 3000) {\n // Check if port 3000 is in use (likely by the dev server)\n const testServer = net.createServer();\n const portInUse = await new Promise<boolean>((resolve) => {\n testServer.listen(3000, () => {\n testServer.close(() => resolve(false));\n });\n testServer.on('error', () => resolve(true));\n setTimeout(() => {\n testServer.close(() => resolve(false));\n }, 100);\n });\n\n if (portInUse) {\n return NextResponse.json(\n { \n status: 'stopped', \n error: 'Port 3000 is already in use by the development server. Please configure a different port (e.g., 3001) in the settings above.' \n },\n { status: 400 }\n );\n }\n }\n\n // Validate port\n if (isNaN(targetPort) || targetPort < 1 || targetPort > 65535) {\n return NextResponse.json(\n { status: 'stopped', error: 'Invalid port number' },\n { status: 400 }\n );\n }\n\n const result = await serviceManager.start(targetPort);\n \n if (result.error) {\n return NextResponse.json(result, { status: 400 });\n }\n\n return NextResponse.json(result);\n } catch (error: any) {\n console.error('Service start API error:', error);\n return NextResponse.json(\n { status: 'stopped', error: error.message || 'Failed to start service' },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/service/start/route\",\n pathname: \"/api/service/start\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/service/start/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/service/start/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAM,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,EAAA,IAAI,EAsXnB,EAAiB,IA5W9B,AA4WkC,MA5W5B,AACI,eAAsC,IAAK,CAC3C,YAAsB,CAAM,AAKpC,OAAc,mBAAmB,CAAW,CAAoB,CAC9D,GAAI,CAEF,OADA,MAAM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AG,CAAC,gBAAiB,CAAA,EAAA,EAAA,qBAAqB,AAArB,EAAsB,EAAW,YAAY,GAE9E,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAChC,IAAI,SAAS,EAAW,KAAK,CAAC,IAAI,CAAE,SAChC,EACA,OAAQ,EAAW,KAAK,CAAC,MAAM,EAAI,GACvC,IACO,IACX,EAGI,EACA,MAAM,EAAe,EADT,CAGZ,MAAM,EAAO,qBAAqB,CAAC,EAAI,OAAO,CAAE,IAAI,EAAO,KAAK,CAAC,EAAA,cAAc,CAAC,aAAa,CAAE,CACvF,SAAU,CAAA,EAAG,EAAO,CAAC,EAAE,EAAA,CAAS,CAChC,KAAM,EAAA,QAAQ,CAAC,MAAM,CACrB,WAAY,CACR,cAAe,EACf,cAAe,EAAI,GAAG,AAC1B,CACJ,EAAG,GAEf,CAAE,MAAO,EAAK,CAeV,GAdM,aAAe,EAAA,eAAe,EAEhC,CAFmC,KAE7B,EAAY,cAAc,CAAC,EAAK,EAAK,CACvC,WAAY,aACZ,UAAW,EACX,UAAW,QACX,iBAAkB,CAAA,EAAA,EAAA,mBAAA,AAAmB,EAAC,oBAClC,uBACA,CACJ,EACJ,GAAG,AATgB,EASJ,GAIf,EAAO,MAAM,EAKjB,OAHA,MAAM,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,EAAa,EAAa,IAAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[2]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},4446,(e,t,r)=>{t.exports=e.x("net",()=>require("net"))},77922,e=>{"use strict";var t=e.i(33405),r=e.i(24361),s=e.i(14747),a=e.i(97731),i=e.i(71560),o=e.i(4446);let n=(0,r.promisify)(t.exec),l=new class{gatewayProcess=null;isStarting=!1;async checkProcessExists(e){try{return await n(`ps -p ${e} -o pid=`),!0}catch{return!1}}async checkPortAvailable(e){return new Promise(t=>{let r=o.default.createServer();r.listen(e,()=>{r.once("close",()=>t(!0)),r.close()}),r.on("error",()=>{t(!1)})})}async getPidByPort(e){try{let{stdout:t}=await n(`lsof -ti:${e} 2>/dev/null || echo ''`),r=t.trim();if(r&&!isNaN(parseInt(r)))return parseInt(r);try{let{stdout:t}=await n(`netstat -tlnp 2>/dev/null | grep :${e} | awk '{print $7}' | cut -d'/' -f1 || echo ''`),r=t.trim();if(r&&!isNaN(parseInt(r)))return parseInt(r)}catch{}return null}catch{return null}}async forceKillProcess(e){try{try{process.kill(e,"SIGTERM"),await new Promise(e=>setTimeout(e,1e3))}catch{}if(await this.checkProcessExists(e))try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch{}return!await this.checkProcessExists(e)}catch(t){return console.error(`Failed to kill process ${e}:`,t),!1}}async killProcessByPort(e){return this.forceKillProcessByPort(e)}async forceKillProcessByPort(e){let t=await this.getPidByPort(e);if(!t)return!0;console.log(`Found process ${t} using port ${e}, attempting to kill...`);let r=await this.forceKillProcess(t);return r?console.log(`Successfully killed process ${t}`):console.warn(`Failed to kill process ${t}`),r}async getStatus(){let e=await (0,a.getServiceStatus)();return e?"running"===e.status&&e.pid&&!await this.checkProcessExists(e.pid)?(await (0,a.updateServiceStatus)({status:"stopped",pid:null}),{status:"stopped"}):{status:e.status,port:e.port,pid:e.pid,started_at:e.started_at}:{status:"stopped"}}async start(e){if(this.isStarting)return{status:"stopped",error:"Service is already starting"};let r=await this.getStatus();if("running"===r.status&&r.port===e)return{status:"running",error:"Service is already running",port:r.port,pid:r.pid};if(!await this.checkPortAvailable(e)){if(console.log(`Port ${e} is in use, attempting to free it...`),await this.killProcessByPort(e),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(e))return{status:"stopped",error:`Port ${e} is still in use after cleanup attempt`};console.log(`Port ${e} is now available`)}this.isStarting=!0;try{try{await (0,i.getDatabase)()}catch(e){return console.error("Failed to initialize database:",e),this.isStarting=!1,{status:"stopped",error:"Failed to initialize database"}}let r=s.default.join(process.cwd(),"dist","src","cli","gateway-server.js"),o=(0,t.spawn)(process.execPath,[r,"--port",e.toString()],{cwd:process.cwd(),stdio:["ignore","pipe","pipe"],env:{...process.env,NODE_ENV:"production"}});o.stdout&&o.stdout.on("data",e=>{process.stdout.write(`[Gateway] ${e}`)}),o.stderr&&o.stderr.on("data",e=>{process.stderr.write(`[Gateway Error] ${e}`)}),o.on("exit",async e=>{console.log(`Gateway process exited with code ${e}`),this.gatewayProcess===o&&(this.gatewayProcess=null,await (0,a.updateServiceStatus)({status:"stopped",pid:null}))}),o.on("error",e=>{console.error(`Failed to start gateway process: ${e.message}`)}),this.gatewayProcess=o;let n=o.pid||null,l=new Date().toISOString();return await (0,a.setServiceStatus)({status:"running",port:e,pid:n,started_at:l}),this.isStarting=!1,console.log(`Gateway server started on port ${e} (PID: ${n})`),{status:"running",port:e,pid:n,started_at:l}}catch(e){return this.isStarting=!1,this.gatewayProcess=null,console.error(`Failed to start gateway service: ${e.message}`),{status:"stopped",error:e.message||"Failed to start service"}}}async stop(){let e=await this.getStatus();if("stopped"===e.status)return{status:"stopped"};let t=e.port||parseInt((await (0,a.getConfig)("port"))?.value||"1357");try{if(this.gatewayProcess&&this.gatewayProcess.pid){let e=this.gatewayProcess.pid;console.log(`Attempting to kill gateway process (PID: ${e})`);try{process.kill(e,"SIGTERM"),console.log(`Sent SIGTERM to process ${e}`),await new Promise(e=>setTimeout(e,1e3))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGTERM failed for process ${e}: ${t.message}`)}if(await this.checkProcessExists(e)){console.log(`Process ${e} still exists after SIGTERM, sending SIGKILL`);try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGKILL failed for process ${e}: ${t.message}`)}}await this.checkProcessExists(e)?console.warn(`Process ${e} still exists after kill attempts`):console.log(`Successfully killed gateway process ${e}`),this.gatewayProcess=null}if(await new Promise(e=>setTimeout(e,500)),!await this.checkPortAvailable(t)&&(console.log(`Port ${t} still in use, attempting to free it...`),await this.killProcessByPort(t),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(t)))return console.error(`Failed to free port ${t} - it may be in TIME_WAIT state`),{status:"stopped",error:`Port ${t} is still in use. It may be in TIME_WAIT state and will be available shortly.`};return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,console.log("Gateway service stopped"),{status:"stopped"}}catch(e){return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,{status:"stopped",error:e.message||"Failed to stop service"}}}};e.s(["serviceManager",0,l])},26511,e=>{"use strict";var t=e.i(47909),r=e.i(74017),s=e.i(96250),a=e.i(59756),i=e.i(61916),o=e.i(74677),n=e.i(69741),l=e.i(16795),c=e.i(87718),u=e.i(95169),p=e.i(47587),d=e.i(66012),h=e.i(70101),g=e.i(26937),w=e.i(10372),y=e.i(93695);e.i(52474);var v=e.i(220),x=e.i(89171),P=e.i(71560),f=e.i(77922);async function m(e){try{(0,P.getDatabase)();let e=await f.serviceManager.getStatus();return x.NextResponse.json(e)}catch(e){return console.error("Service status API error:",e),x.NextResponse.json({status:"stopped",error:e.message||"Failed to get service status"},{status:500})}}e.s(["GET",()=>m,"runtime",0,"nodejs"],79041);var R=e.i(79041);let S=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/service/status/route",pathname:"/api/service/status",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/service/status/route.ts",nextConfigOutput:"",userland:R}),{workAsyncStorage:E,workUnitAsyncStorage:k,serverHooks:I}=S;function $(){return(0,s.patchFetch)({workAsyncStorage:E,workUnitAsyncStorage:k})}async function b(e,t,s){S.isDev&&(0,a.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/service/status/route";x=x.replace(/\/index$/,"")||"/";let P=await S.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!P)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:f,params:m,nextConfig:R,parsedUrl:E,isDraftMode:k,prerenderManifest:I,routerServerContext:$,isOnDemandRevalidate:b,revalidateOnlyGenerated:T,resolvedPathname:C,clientReferenceManifest:A,serverActionsManifest:N}=P,_=(0,n.normalizeAppPath)(x),q=!!(I.dynamicRoutes[_]||I.routes[C]),O=async()=>((null==$?void 0:$.render404)?await $.render404(e,t,E,!1):t.end("This page could not be found"),null);if(q&&!k){let e=!!I.routes[C],t=I.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(R.experimental.adapterPath)return await O();throw new y.NoFallbackError}}let j=null;!q||S.isDev||k||(j="/index"===(j=C)?"/":j);let H=!0===S.isDev||!q,M=q&&!H;N&&A&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:A,serverActionsManifest:N});let D=e.method||"GET",F=(0,i.getTracer)(),G=F.getActiveScopeSpan(),K={params:m,prerenderManifest:I,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:H,incrementalCache:(0,a.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:R.cacheLife,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,s,a)=>S.onRequestError(e,t,s,a,$)},sharedContext:{buildId:f}},U=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),B=c.NextRequestAdapter.fromNodeNextRequest(U,(0,c.signalFromNodeResponse)(t));try{let o=async e=>S.handle(B,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=r.get("next.route");if(s){let t=`${D} ${s}`;e.setAttributes({"next.route":s,"http.route":s,"next.span_name":t}),e.updateName(t)}else e.updateName(`${D} ${x}`)}),n=!!(0,a.getRequestMeta)(e,"minimalMode"),l=async a=>{var i,l;let c=async({previousCacheEntry:r})=>{try{if(!n&&b&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await o(a);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&s.waitUntil&&(s.waitUntil(l),l=void 0);let c=K.renderOpts.collectedTags;if(!q)return await (0,d.sendResponse)(U,L,i,K.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);c&&(t[w.NEXT_CACHE_TAGS_HEADER]=c),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=w.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,s=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=w.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:s}}}}catch(t){throw(null==r?void 0:r.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:b})},!1,$),t}},u=await S.handleResponse({req:e,nextConfig:R,cacheKey:j,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:I,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:T,responseGenerator:c,waitUntil:s.waitUntil,isMinimalMode:n});if(!q)return null;if((null==u||null==(i=u.value)?void 0:i.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});n||t.setHeader("x-nextjs-cache",b?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),k&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return n&&q||y.delete(w.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,d.sendResponse)(U,L,new Response(u.value.body,{headers:y,status:u.value.status||200})),null};G?await l(G):await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${D} ${x}`,kind:i.SpanKind.SERVER,attributes:{"http.method":D,"http.target":e.url}},l))}catch(t){if(t instanceof y.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:b})},!1,$),q)throw t;return await (0,d.sendResponse)(U,L,new Response(null,{status:500})),null}}e.s(["handler",()=>b,"patchFetch",()=>$,"routeModule",()=>S,"serverHooks",()=>I,"workAsyncStorage",()=>E,"workUnitAsyncStorage",()=>k],26511)}];
|
|
1
|
+
module.exports=[93695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},14747,(e,t,r)=>{t.exports=e.x("path",()=>require("path"))},70406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},18622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},56704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},32319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},24725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},24361,(e,t,r)=>{t.exports=e.x("util",()=>require("util"))},33405,(e,t,r)=>{t.exports=e.x("child_process",()=>require("child_process"))},4446,(e,t,r)=>{t.exports=e.x("net",()=>require("net"))},77922,e=>{"use strict";var t=e.i(33405),r=e.i(24361),s=e.i(14747),a=e.i(97731),i=e.i(71560),o=e.i(4446);let n=(0,r.promisify)(t.exec),l=new class{gatewayProcess=null;isStarting=!1;async checkProcessExists(e){try{return await n(`ps -p ${e} -o pid=`),!0}catch{return!1}}async checkPortAvailable(e){return new Promise(t=>{let r=o.default.createServer();r.listen(e,()=>{r.once("close",()=>t(!0)),r.close()}),r.on("error",()=>{t(!1)})})}async getPidByPort(e){try{let{stdout:t}=await n(`lsof -ti:${e} 2>/dev/null || echo ''`),r=t.trim();if(r&&!isNaN(parseInt(r)))return parseInt(r);try{let{stdout:t}=await n(`netstat -tlnp 2>/dev/null | grep :${e} | awk '{print $7}' | cut -d'/' -f1 || echo ''`),r=t.trim();if(r&&!isNaN(parseInt(r)))return parseInt(r)}catch{}return null}catch{return null}}async forceKillProcess(e){try{try{process.kill(e,"SIGTERM"),await new Promise(e=>setTimeout(e,1e3))}catch{}if(await this.checkProcessExists(e))try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch{}return!await this.checkProcessExists(e)}catch(t){return console.error(`Failed to kill process ${e}:`,t),!1}}async killProcessByPort(e){return this.forceKillProcessByPort(e)}async forceKillProcessByPort(e){let t=await this.getPidByPort(e);if(!t)return!0;console.log(`Found process ${t} using port ${e}, attempting to kill...`);let r=await this.forceKillProcess(t);return r?console.log(`Successfully killed process ${t}`):console.warn(`Failed to kill process ${t}`),r}async getStatus(){let e=await (0,a.getServiceStatus)();return e?"running"===e.status&&e.pid&&!await this.checkProcessExists(e.pid)?(await (0,a.updateServiceStatus)({status:"stopped",pid:null}),{status:"stopped"}):{status:e.status,port:e.port,pid:e.pid,started_at:e.started_at}:{status:"stopped"}}async start(e){if(this.isStarting)return{status:"stopped",error:"Service is already starting"};let r=await this.getStatus();if("running"===r.status&&r.port===e)return{status:"running",error:"Service is already running",port:r.port,pid:r.pid};if(!await this.checkPortAvailable(e)){if(console.log(`Port ${e} is in use, attempting to free it...`),await this.killProcessByPort(e),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(e))return{status:"stopped",error:`Port ${e} is still in use after cleanup attempt`};console.log(`Port ${e} is now available`)}this.isStarting=!0;try{try{await (0,i.getDatabase)()}catch(e){return console.error("Failed to initialize database:",e),this.isStarting=!1,{status:"stopped",error:"Failed to initialize database"}}let r=s.default.join(process.cwd(),"dist","src","cli","gateway-server.js"),o=(0,t.spawn)(process.execPath,[r,"--port",e.toString()],{cwd:process.cwd(),stdio:["ignore","pipe","pipe"],env:{...process.env,NODE_ENV:"production"}});o.stdout&&o.stdout.on("data",e=>{process.stdout.write(`[Gateway] ${e}`)}),o.stderr&&o.stderr.on("data",e=>{process.stderr.write(`[Gateway Error] ${e}`)}),o.on("exit",async e=>{console.log(`Gateway process exited with code ${e}`),this.gatewayProcess===o&&(this.gatewayProcess=null,await (0,a.updateServiceStatus)({status:"stopped",pid:null}))}),o.on("error",e=>{console.error(`Failed to start gateway process: ${e.message}`)}),this.gatewayProcess=o;let n=o.pid||null,l=new Date().toISOString();return await (0,a.setServiceStatus)({status:"running",port:e,pid:n,started_at:l}),this.isStarting=!1,console.log(`Gateway server started on port ${e} (PID: ${n})`),{status:"running",port:e,pid:n,started_at:l}}catch(e){return this.isStarting=!1,this.gatewayProcess=null,console.error(`Failed to start gateway service: ${e.message}`),{status:"stopped",error:e.message||"Failed to start service"}}}async stop(){let e=await this.getStatus();if("stopped"===e.status)return{status:"stopped"};let t=e.port||parseInt((await (0,a.getConfig)("port"))?.value||"1357");try{if(this.gatewayProcess&&this.gatewayProcess.pid){let e=this.gatewayProcess.pid;console.log(`Attempting to kill gateway process (PID: ${e})`);try{process.kill(e,"SIGTERM"),console.log(`Sent SIGTERM to process ${e}`),await new Promise(e=>setTimeout(e,1e3))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGTERM failed for process ${e}: ${t.message}`)}if(await this.checkProcessExists(e)){console.log(`Process ${e} still exists after SIGTERM, sending SIGKILL`);try{process.kill(e,"SIGKILL"),await new Promise(e=>setTimeout(e,500))}catch(t){"ESRCH"===t.code?console.log(`Process ${e} already dead (ESRCH)`):console.log(`SIGKILL failed for process ${e}: ${t.message}`)}}await this.checkProcessExists(e)?console.warn(`Process ${e} still exists after kill attempts`):console.log(`Successfully killed gateway process ${e}`),this.gatewayProcess=null}if(await new Promise(e=>setTimeout(e,500)),!await this.checkPortAvailable(t)&&(console.log(`Port ${t} still in use, attempting to free it...`),await this.killProcessByPort(t),await new Promise(e=>setTimeout(e,1e3)),!await this.checkPortAvailable(t)))return console.error(`Failed to free port ${t} - it may be in TIME_WAIT state`),{status:"stopped",error:`Port ${t} is still in use. It may be in TIME_WAIT state and will be available shortly.`};return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,console.log("Gateway service stopped"),{status:"stopped"}}catch(e){return await (0,a.updateServiceStatus)({status:"stopped",pid:null}),this.gatewayProcess=null,{status:"stopped",error:e.message||"Failed to stop service"}}}};e.s(["serviceManager",0,l])},26511,e=>{"use strict";var t=e.i(47909),r=e.i(74017),s=e.i(96250),a=e.i(59756),i=e.i(61916),o=e.i(74677),n=e.i(69741),l=e.i(16795),c=e.i(87718),u=e.i(95169),p=e.i(47587),d=e.i(66012),h=e.i(70101),g=e.i(26937),w=e.i(10372),y=e.i(93695);e.i(52474);var v=e.i(220),x=e.i(89171),P=e.i(71560),f=e.i(77922);async function m(e){try{await (0,P.getDatabase)();let e=await f.serviceManager.getStatus();return x.NextResponse.json(e)}catch(e){return console.error("Service status API error:",e),x.NextResponse.json({status:"stopped",error:e.message||"Failed to get service status"},{status:500})}}e.s(["GET",()=>m,"runtime",0,"nodejs"],79041);var R=e.i(79041);let S=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/service/status/route",pathname:"/api/service/status",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/service/status/route.ts",nextConfigOutput:"",userland:R}),{workAsyncStorage:E,workUnitAsyncStorage:k,serverHooks:I}=S;function $(){return(0,s.patchFetch)({workAsyncStorage:E,workUnitAsyncStorage:k})}async function b(e,t,s){S.isDev&&(0,a.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let x="/api/service/status/route";x=x.replace(/\/index$/,"")||"/";let P=await S.prepare(e,t,{srcPage:x,multiZoneDraftMode:!1});if(!P)return t.statusCode=400,t.end("Bad Request"),null==s.waitUntil||s.waitUntil.call(s,Promise.resolve()),null;let{buildId:f,params:m,nextConfig:R,parsedUrl:E,isDraftMode:k,prerenderManifest:I,routerServerContext:$,isOnDemandRevalidate:b,revalidateOnlyGenerated:T,resolvedPathname:C,clientReferenceManifest:A,serverActionsManifest:N}=P,_=(0,n.normalizeAppPath)(x),q=!!(I.dynamicRoutes[_]||I.routes[C]),O=async()=>((null==$?void 0:$.render404)?await $.render404(e,t,E,!1):t.end("This page could not be found"),null);if(q&&!k){let e=!!I.routes[C],t=I.dynamicRoutes[_];if(t&&!1===t.fallback&&!e){if(R.experimental.adapterPath)return await O();throw new y.NoFallbackError}}let j=null;!q||S.isDev||k||(j="/index"===(j=C)?"/":j);let H=!0===S.isDev||!q,M=q&&!H;N&&A&&(0,o.setManifestsSingleton)({page:x,clientReferenceManifest:A,serverActionsManifest:N});let D=e.method||"GET",F=(0,i.getTracer)(),G=F.getActiveScopeSpan(),K={params:m,prerenderManifest:I,renderOpts:{experimental:{authInterrupts:!!R.experimental.authInterrupts},cacheComponents:!!R.cacheComponents,supportsDynamicResponse:H,incrementalCache:(0,a.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:R.cacheLife,waitUntil:s.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,s,a)=>S.onRequestError(e,t,s,a,$)},sharedContext:{buildId:f}},U=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),B=c.NextRequestAdapter.fromNodeNextRequest(U,(0,c.signalFromNodeResponse)(t));try{let o=async e=>S.handle(B,K).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=F.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let s=r.get("next.route");if(s){let t=`${D} ${s}`;e.setAttributes({"next.route":s,"http.route":s,"next.span_name":t}),e.updateName(t)}else e.updateName(`${D} ${x}`)}),n=!!(0,a.getRequestMeta)(e,"minimalMode"),l=async a=>{var i,l;let c=async({previousCacheEntry:r})=>{try{if(!n&&b&&T&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await o(a);e.fetchMetrics=K.renderOpts.fetchMetrics;let l=K.renderOpts.pendingWaitUntil;l&&s.waitUntil&&(s.waitUntil(l),l=void 0);let c=K.renderOpts.collectedTags;if(!q)return await (0,d.sendResponse)(U,L,i,K.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(i.headers);c&&(t[w.NEXT_CACHE_TAGS_HEADER]=c),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==K.renderOpts.collectedRevalidate&&!(K.renderOpts.collectedRevalidate>=w.INFINITE_CACHE)&&K.renderOpts.collectedRevalidate,s=void 0===K.renderOpts.collectedExpire||K.renderOpts.collectedExpire>=w.INFINITE_CACHE?void 0:K.renderOpts.collectedExpire;return{value:{kind:v.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:s}}}}catch(t){throw(null==r?void 0:r.isStale)&&await S.onRequestError(e,t,{routerKind:"App Router",routePath:x,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:b})},!1,$),t}},u=await S.handleResponse({req:e,nextConfig:R,cacheKey:j,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:I,isRoutePPREnabled:!1,isOnDemandRevalidate:b,revalidateOnlyGenerated:T,responseGenerator:c,waitUntil:s.waitUntil,isMinimalMode:n});if(!q)return null;if((null==u||null==(i=u.value)?void 0:i.kind)!==v.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});n||t.setHeader("x-nextjs-cache",b?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),k&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let y=(0,h.fromNodeOutgoingHttpHeaders)(u.value.headers);return n&&q||y.delete(w.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||y.get("Cache-Control")||y.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,d.sendResponse)(U,L,new Response(u.value.body,{headers:y,status:u.value.status||200})),null};G?await l(G):await F.withPropagatedContext(e.headers,()=>F.trace(u.BaseServerSpan.handleRequest,{spanName:`${D} ${x}`,kind:i.SpanKind.SERVER,attributes:{"http.method":D,"http.target":e.url}},l))}catch(t){if(t instanceof y.NoFallbackError||await S.onRequestError(e,t,{routerKind:"App Router",routePath:_,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:M,isOnDemandRevalidate:b})},!1,$),q)throw t;return await (0,d.sendResponse)(U,L,new Response(null,{status:500})),null}}e.s(["handler",()=>b,"patchFetch",()=>$,"routeModule",()=>S,"serverHooks",()=>I,"workAsyncStorage",()=>E,"workUnitAsyncStorage",()=>k],26511)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=%5Broot-of-the-server%5D__7b77f523._.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/service-manager.ts","../../../src/app/api/service/status/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n","import { NextRequest, NextResponse } from 'next/server';\nimport { getDatabase } from '@/db/database';\nimport { serviceManager } from '@/server/service-manager';\n\n// Ensure Node.js runtime (required for service manager)\nexport const runtime = 'nodejs';\n\nexport async function GET(request: NextRequest) {\n try {\n // Initialize database\n getDatabase();\n \n const status = await serviceManager.getStatus();\n return NextResponse.json(status);\n } catch (error: any) {\n console.error('Service status API error:', error);\n return NextResponse.json(\n { status: 'stopped', error: error.message || 'Failed to get service status' },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/service/status/route\",\n pathname: \"/api/service/status\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/service/status/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/service/status/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAM,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,EAAA,IAAI,EAsXnB,EAAiB,IA5W9B,AA4WkC,MA5W5B,AACI,eAAsC,IAAK,CAC3C,YAAsB,CAAM,AAKpC,OAAc,mBAAmB,CAAW,CAAoB,CAC9D,GAAI,CAEF,OADA,MAAM,EAAU,CAAC,MAAM,EAAE,EAAI,QAAQ,CAAC,GAC/B,CACT,CAAE,KAAM,CACN,OAAO,CACT,CACF,CAKA,MAAc,mBAAmB,CAAY,CAAoB,CAC/D,OAAO,IAAI,QAAQ,AAAC,IAClB,IAAM,EAAS,EAAA,OAAG,CAAC,YAAY,GAE/B,EAAO,MAAM,CAAC,EAAM,KAClB,EAAO,IA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AAI,SAAS,KAAM,CAC5D,OAAQ,GACZ,IACO,IACX,CACJ,EAEA,qCAAqC","ignoreList":[2]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/service-manager.ts","../../../src/app/api/service/status/route.ts","../../../node_modules/next/dist/esm/build/templates/app-route.js"],"sourcesContent":["import { exec, execSync, spawn, ChildProcess } from 'child_process';\nimport { promisify } from 'util';\nimport path from 'path';\nimport { getServiceStatus, setServiceStatus, updateServiceStatus, getConfig } from '@/db/queries';\nimport { getDatabase } from '@/db/database';\nimport net from 'net';\n\nconst execAsync = promisify(exec);\n\nexport interface ServiceStatusResponse {\n status: 'running' | 'stopped';\n port?: number;\n pid?: number | null;\n started_at?: string | null;\n error?: string;\n}\n\nclass ServiceManager {\n private gatewayProcess: ChildProcess | null = null;\n private isStarting: boolean = false;\n\n /**\n * Check if a process with given PID exists\n */\n private async checkProcessExists(pid: number): Promise<boolean> {\n try {\n await execAsync(`ps -p ${pid} -o pid=`);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Check if a port is available\n */\n private async checkPortAvailable(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const server = net.createServer();\n\n server.listen(port, () => {\n server.once('close', () => resolve(true));\n server.close();\n });\n\n server.on('error', () => {\n resolve(false);\n });\n });\n }\n\n /**\n * Get PID using a specific port\n */\n private async getPidByPort(port: number): Promise<number | null> {\n try {\n // Try lsof first (macOS/Linux)\n const { stdout } = await execAsync(`lsof -ti:${port} 2>/dev/null || echo ''`);\n const pid = stdout.trim();\n if (pid && !isNaN(parseInt(pid))) {\n return parseInt(pid);\n }\n\n // Try netstat as fallback (some systems)\n try {\n const { stdout: netstatOut } = await execAsync(`netstat -tlnp 2>/dev/null | grep :${port} | awk '{print $7}' | cut -d'/' -f1 || echo ''`);\n const pid2 = netstatOut.trim();\n if (pid2 && !isNaN(parseInt(pid2))) {\n return parseInt(pid2);\n }\n } catch {\n // netstat might not be available\n }\n\n return null;\n } catch {\n return null;\n }\n }\n\n /**\n * Force kill a process by PID\n */\n private async forceKillProcess(pid: number): Promise<boolean> {\n try {\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch {\n // Process might already be dead\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n // Try SIGKILL\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch {\n // Might fail if process already dead\n }\n }\n\n return !(await this.checkProcessExists(pid));\n } catch (error) {\n console.error(`Failed to kill process ${pid}:`, error);\n return false;\n }\n }\n\n /**\n * Kill process using a specific port (public method)\n */\n async killProcessByPort(port: number): Promise<boolean> {\n return this.forceKillProcessByPort(port);\n }\n\n /**\n * Force kill a process by PID (private helper)\n */\n private async forceKillProcessByPort(port: number): Promise<boolean> {\n const pid = await this.getPidByPort(port);\n if (!pid) {\n return true; // No process using the port\n }\n\n console.log(`Found process ${pid} using port ${port}, attempting to kill...`);\n const killed = await this.forceKillProcess(pid);\n \n if (killed) {\n console.log(`Successfully killed process ${pid}`);\n } else {\n console.warn(`Failed to kill process ${pid}`);\n }\n\n return killed;\n }\n\n /**\n * Get current service status, verifying process existence\n */\n async getStatus(): Promise<ServiceStatusResponse> {\n const dbStatus = await getServiceStatus();\n\n if (!dbStatus) {\n return { status: 'stopped' };\n }\n\n // If status is running, verify process actually exists\n if (dbStatus.status === 'running' && dbStatus.pid) {\n const processExists = await this.checkProcessExists(dbStatus.pid);\n if (!processExists) {\n // Process doesn't exist, update database\n await updateServiceStatus({ status: 'stopped', pid: null });\n return { status: 'stopped' };\n }\n }\n\n return {\n status: dbStatus.status,\n port: dbStatus.port,\n pid: dbStatus.pid,\n started_at: dbStatus.started_at,\n };\n }\n\n /**\n * Start gateway service\n */\n async start(port: number): Promise<ServiceStatusResponse> {\n // Prevent concurrent starts\n if (this.isStarting) {\n return { status: 'stopped', error: 'Service is already starting' };\n }\n\n // Check if service is already running\n const currentStatus = await this.getStatus();\n if (currentStatus.status === 'running' && currentStatus.port === port) {\n return { status: 'running', error: 'Service is already running', port: currentStatus.port, pid: currentStatus.pid };\n }\n\n // Check if port is available\n const portAvailable = await this.checkPortAvailable(port);\n if (!portAvailable) {\n console.log(`Port ${port} is in use, attempting to free it...`);\n\n // Try to kill the process using the port\n const killed = await this.killProcessByPort(port);\n\n // Wait for port to be released\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n // Check again\n const portNowAvailable = await this.checkPortAvailable(port);\n if (!portNowAvailable) {\n return { status: 'stopped', error: `Port ${port} is still in use after cleanup attempt` };\n }\n\n console.log(`Port ${port} is now available`);\n }\n\n this.isStarting = true;\n\n try {\n // Initialize database\n try {\n await getDatabase();\n } catch (error: any) {\n console.error('Failed to initialize database:', error);\n this.isStarting = false;\n return { status: 'stopped', error: 'Failed to initialize database' };\n }\n\n // Get the path to the gateway server entry script\n const gatewayScriptPath = path.join(process.cwd(), 'dist', 'src', 'cli', 'gateway-server.js');\n\n // Spawn the gateway server in a separate process\n const gatewayProcess = spawn(process.execPath, [gatewayScriptPath, '--port', port.toString()], {\n cwd: process.cwd(),\n stdio: ['ignore', 'pipe', 'pipe'],\n env: { ...process.env, NODE_ENV: process.env.NODE_ENV || 'development' },\n });\n\n // Capture process output\n if (gatewayProcess.stdout) {\n gatewayProcess.stdout.on('data', (data) => {\n process.stdout.write(`[Gateway] ${data}`);\n });\n }\n if (gatewayProcess.stderr) {\n gatewayProcess.stderr.on('data', (data) => {\n process.stderr.write(`[Gateway Error] ${data}`);\n });\n }\n\n // Handle process exit\n gatewayProcess.on('exit', async (code) => {\n console.log(`Gateway process exited with code ${code}`);\n if (this.gatewayProcess === gatewayProcess) {\n this.gatewayProcess = null;\n await updateServiceStatus({ status: 'stopped', pid: null });\n }\n });\n\n gatewayProcess.on('error', (error) => {\n console.error(`Failed to start gateway process: ${error.message}`);\n });\n\n this.gatewayProcess = gatewayProcess;\n const pid = gatewayProcess.pid || null;\n const startedAt = new Date().toISOString();\n\n await setServiceStatus({\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n });\n\n this.isStarting = false;\n\n console.log(`Gateway server started on port ${port} (PID: ${pid})`);\n\n return {\n status: 'running',\n port,\n pid,\n started_at: startedAt,\n };\n } catch (error: any) {\n this.isStarting = false;\n this.gatewayProcess = null;\n console.error(`Failed to start gateway service: ${error.message}`);\n return { status: 'stopped', error: error.message || 'Failed to start service' };\n }\n }\n\n /**\n * Stop the gateway service\n */\n async stop(): Promise<ServiceStatusResponse> {\n const currentStatus = await this.getStatus();\n\n if (currentStatus.status === 'stopped') {\n return { status: 'stopped' };\n }\n\n const port = currentStatus.port || parseInt((await getConfig('port'))?.value || '1357');\n\n try {\n // Track if we successfully killed something\n let killedSuccessfully = false;\n\n // Try to stop the gateway server process\n if (this.gatewayProcess && this.gatewayProcess.pid) {\n const pid = this.gatewayProcess.pid;\n console.log(`Attempting to kill gateway process (PID: ${pid})`);\n\n // First try SIGTERM for graceful shutdown\n try {\n process.kill(pid, 'SIGTERM');\n console.log(`Sent SIGTERM to process ${pid}`);\n // Give process time to terminate gracefully\n await new Promise(resolve => setTimeout(resolve, 1000));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGTERM failed for process ${pid}: ${error.message}`);\n }\n }\n\n // Check if process still exists\n if (await this.checkProcessExists(pid)) {\n console.log(`Process ${pid} still exists after SIGTERM, sending SIGKILL`);\n try {\n process.kill(pid, 'SIGKILL');\n await new Promise(resolve => setTimeout(resolve, 500));\n } catch (error: any) {\n if (error.code === 'ESRCH') {\n console.log(`Process ${pid} already dead (ESRCH)`);\n } else {\n console.log(`SIGKILL failed for process ${pid}: ${error.message}`);\n }\n }\n }\n\n // Verify process is dead\n if (!(await this.checkProcessExists(pid))) {\n console.log(`Successfully killed gateway process ${pid}`);\n killedSuccessfully = true;\n } else {\n console.warn(`Process ${pid} still exists after kill attempts`);\n }\n\n this.gatewayProcess = null;\n }\n\n // Wait a bit for cleanup\n await new Promise(resolve => setTimeout(resolve, 500));\n\n // Check if port is still in use - if so, force kill by port\n const portStillInUse = !(await this.checkPortAvailable(port));\n\n if (portStillInUse) {\n console.log(`Port ${port} still in use, attempting to free it...`);\n const killed = await this.killProcessByPort(port);\n\n // Wait and verify\n await new Promise(resolve => setTimeout(resolve, 1000));\n\n const stillInUse = !(await this.checkPortAvailable(port));\n if (stillInUse) {\n console.error(`Failed to free port ${port} - it may be in TIME_WAIT state`);\n return {\n status: 'stopped',\n error: `Port ${port} is still in use. It may be in TIME_WAIT state and will be available shortly.`,\n };\n }\n\n killedSuccessfully = true;\n }\n\n // Update database status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n\n console.log('Gateway service stopped');\n return { status: 'stopped' };\n } catch (error: any) {\n // Even if there's an error, try to update status\n await updateServiceStatus({ status: 'stopped', pid: null });\n this.gatewayProcess = null;\n return { status: 'stopped', error: error.message || 'Failed to stop service' };\n }\n }\n}\n\n// Export singleton instance\nexport const serviceManager = new ServiceManager();\n","import { NextRequest, NextResponse } from 'next/server';\nimport { getDatabase } from '@/db/database';\nimport { serviceManager } from '@/server/service-manager';\n\n// Ensure Node.js runtime (required for service manager)\nexport const runtime = 'nodejs';\n\nexport async function GET(request: NextRequest) {\n try {\n // Initialize database\n await getDatabase();\n \n const status = await serviceManager.getStatus();\n return NextResponse.json(status);\n } catch (error: any) {\n console.error('Service status API error:', error);\n return NextResponse.json(\n { status: 'stopped', error: error.message || 'Failed to get service status' },\n { status: 500 }\n );\n }\n}\n","import { AppRouteRouteModule } from \"next/dist/esm/server/route-modules/app-route/module.compiled\";\nimport { RouteKind } from \"next/dist/esm/server/route-kind\";\nimport { patchFetch as _patchFetch } from \"next/dist/esm/server/lib/patch-fetch\";\nimport { addRequestMeta, getRequestMeta } from \"next/dist/esm/server/request-meta\";\nimport { getTracer, SpanKind } from \"next/dist/esm/server/lib/trace/tracer\";\nimport { setManifestsSingleton } from \"next/dist/esm/server/app-render/manifests-singleton\";\nimport { normalizeAppPath } from \"next/dist/esm/shared/lib/router/utils/app-paths\";\nimport { NodeNextRequest, NodeNextResponse } from \"next/dist/esm/server/base-http/node\";\nimport { NextRequestAdapter, signalFromNodeResponse } from \"next/dist/esm/server/web/spec-extension/adapters/next-request\";\nimport { BaseServerSpan } from \"next/dist/esm/server/lib/trace/constants\";\nimport { getRevalidateReason } from \"next/dist/esm/server/instrumentation/utils\";\nimport { sendResponse } from \"next/dist/esm/server/send-response\";\nimport { fromNodeOutgoingHttpHeaders, toNodeOutgoingHttpHeaders } from \"next/dist/esm/server/web/utils\";\nimport { getCacheControlHeader } from \"next/dist/esm/server/lib/cache-control\";\nimport { INFINITE_CACHE, NEXT_CACHE_TAGS_HEADER } from \"next/dist/esm/lib/constants\";\nimport { NoFallbackError } from \"next/dist/esm/shared/lib/no-fallback-error.external\";\nimport { CachedRouteKind } from \"next/dist/esm/server/response-cache\";\nimport * as userland from \"INNER_APP_ROUTE\";\n// We inject the nextConfigOutput here so that we can use them in the route\n// module.\nconst nextConfigOutput = \"\"\nconst routeModule = new AppRouteRouteModule({\n definition: {\n kind: RouteKind.APP_ROUTE,\n page: \"/api/service/status/route\",\n pathname: \"/api/service/status\",\n filename: \"route\",\n bundlePath: \"\"\n },\n distDir: process.env.__NEXT_RELATIVE_DIST_DIR || '',\n relativeProjectDir: process.env.__NEXT_RELATIVE_PROJECT_DIR || '',\n resolvedPagePath: \"[project]/src/app/api/service/status/route.ts\",\n nextConfigOutput,\n userland\n});\n// Pull out the exports that we need to expose from the module. This should\n// be eliminated when we've moved the other routes to the new format. These\n// are used to hook into the route.\nconst { workAsyncStorage, workUnitAsyncStorage, serverHooks } = routeModule;\nfunction patchFetch() {\n return _patchFetch({\n workAsyncStorage,\n workUnitAsyncStorage\n });\n}\nexport { routeModule, workAsyncStorage, workUnitAsyncStorage, serverHooks, patchFetch, };\nexport async function handler(req, res, ctx) {\n if (routeModule.isDev) {\n addRequestMeta(req, 'devRequestTimingInternalsEnd', process.hrtime.bigint());\n }\n let srcPage = \"/api/service/status/route\";\n // turbopack doesn't normalize `/index` in the page name\n // so we need to to process dynamic routes properly\n // TODO: fix turbopack providing differing value from webpack\n if (process.env.TURBOPACK) {\n srcPage = srcPage.replace(/\\/index$/, '') || '/';\n } else if (srcPage === '/index') {\n // we always normalize /index specifically\n srcPage = '/';\n }\n const multiZoneDraftMode = process.env.__NEXT_MULTI_ZONE_DRAFT_MODE;\n const prepareResult = await routeModule.prepare(req, res, {\n srcPage,\n multiZoneDraftMode\n });\n if (!prepareResult) {\n res.statusCode = 400;\n res.end('Bad Request');\n ctx.waitUntil == null ? void 0 : ctx.waitUntil.call(ctx, Promise.resolve());\n return null;\n }\n const { buildId, params, nextConfig, parsedUrl, isDraftMode, prerenderManifest, routerServerContext, isOnDemandRevalidate, revalidateOnlyGenerated, resolvedPathname, clientReferenceManifest, serverActionsManifest } = prepareResult;\n const normalizedSrcPage = normalizeAppPath(srcPage);\n let isIsr = Boolean(prerenderManifest.dynamicRoutes[normalizedSrcPage] || prerenderManifest.routes[resolvedPathname]);\n const render404 = async ()=>{\n // TODO: should route-module itself handle rendering the 404\n if (routerServerContext == null ? void 0 : routerServerContext.render404) {\n await routerServerContext.render404(req, res, parsedUrl, false);\n } else {\n res.end('This page could not be found');\n }\n return null;\n };\n if (isIsr && !isDraftMode) {\n const isPrerendered = Boolean(prerenderManifest.routes[resolvedPathname]);\n const prerenderInfo = prerenderManifest.dynamicRoutes[normalizedSrcPage];\n if (prerenderInfo) {\n if (prerenderInfo.fallback === false && !isPrerendered) {\n if (nextConfig.experimental.adapterPath) {\n return await render404();\n }\n throw new NoFallbackError();\n }\n }\n }\n let cacheKey = null;\n if (isIsr && !routeModule.isDev && !isDraftMode) {\n cacheKey = resolvedPathname;\n // ensure /index and / is normalized to one key\n cacheKey = cacheKey === '/index' ? '/' : cacheKey;\n }\n const supportsDynamicResponse = // If we're in development, we always support dynamic HTML\n routeModule.isDev === true || // If this is not SSG or does not have static paths, then it supports\n // dynamic HTML.\n !isIsr;\n // This is a revalidation request if the request is for a static\n // page and it is not being resumed from a postponed render and\n // it is not a dynamic RSC request then it is a revalidation\n // request.\n const isStaticGeneration = isIsr && !supportsDynamicResponse;\n // Before rendering (which initializes component tree modules), we have to\n // set the reference manifests to our global store so Server Action's\n // encryption util can access to them at the top level of the page module.\n if (serverActionsManifest && clientReferenceManifest) {\n setManifestsSingleton({\n page: srcPage,\n clientReferenceManifest,\n serverActionsManifest\n });\n }\n const method = req.method || 'GET';\n const tracer = getTracer();\n const activeSpan = tracer.getActiveScopeSpan();\n const context = {\n params,\n prerenderManifest,\n renderOpts: {\n experimental: {\n authInterrupts: Boolean(nextConfig.experimental.authInterrupts)\n },\n cacheComponents: Boolean(nextConfig.cacheComponents),\n supportsDynamicResponse,\n incrementalCache: getRequestMeta(req, 'incrementalCache'),\n cacheLifeProfiles: nextConfig.cacheLife,\n waitUntil: ctx.waitUntil,\n onClose: (cb)=>{\n res.on('close', cb);\n },\n onAfterTaskError: undefined,\n onInstrumentationRequestError: (error, _request, errorContext, silenceLog)=>routeModule.onRequestError(req, error, errorContext, silenceLog, routerServerContext)\n },\n sharedContext: {\n buildId\n }\n };\n const nodeNextReq = new NodeNextRequest(req);\n const nodeNextRes = new NodeNextResponse(res);\n const nextReq = NextRequestAdapter.fromNodeNextRequest(nodeNextReq, signalFromNodeResponse(res));\n try {\n const invokeRouteModule = async (span)=>{\n return routeModule.handle(nextReq, context).finally(()=>{\n if (!span) return;\n span.setAttributes({\n 'http.status_code': res.statusCode,\n 'next.rsc': false\n });\n const rootSpanAttributes = tracer.getRootSpanAttributes();\n // We were unable to get attributes, probably OTEL is not enabled\n if (!rootSpanAttributes) {\n return;\n }\n if (rootSpanAttributes.get('next.span_type') !== BaseServerSpan.handleRequest) {\n console.warn(`Unexpected root span type '${rootSpanAttributes.get('next.span_type')}'. Please report this Next.js issue https://github.com/vercel/next.js`);\n return;\n }\n const route = rootSpanAttributes.get('next.route');\n if (route) {\n const name = `${method} ${route}`;\n span.setAttributes({\n 'next.route': route,\n 'http.route': route,\n 'next.span_name': name\n });\n span.updateName(name);\n } else {\n span.updateName(`${method} ${srcPage}`);\n }\n });\n };\n const isMinimalMode = Boolean(process.env.MINIMAL_MODE || getRequestMeta(req, 'minimalMode'));\n const handleResponse = async (currentSpan)=>{\n var _cacheEntry_value;\n const responseGenerator = async ({ previousCacheEntry })=>{\n try {\n if (!isMinimalMode && isOnDemandRevalidate && revalidateOnlyGenerated && !previousCacheEntry) {\n res.statusCode = 404;\n // on-demand revalidate always sets this header\n res.setHeader('x-nextjs-cache', 'REVALIDATED');\n res.end('This page could not be found');\n return null;\n }\n const response = await invokeRouteModule(currentSpan);\n req.fetchMetrics = context.renderOpts.fetchMetrics;\n let pendingWaitUntil = context.renderOpts.pendingWaitUntil;\n // Attempt using provided waitUntil if available\n // if it's not we fallback to sendResponse's handling\n if (pendingWaitUntil) {\n if (ctx.waitUntil) {\n ctx.waitUntil(pendingWaitUntil);\n pendingWaitUntil = undefined;\n }\n }\n const cacheTags = context.renderOpts.collectedTags;\n // If the request is for a static response, we can cache it so long\n // as it's not edge.\n if (isIsr) {\n const blob = await response.blob();\n // Copy the headers from the response.\n const headers = toNodeOutgoingHttpHeaders(response.headers);\n if (cacheTags) {\n headers[NEXT_CACHE_TAGS_HEADER] = cacheTags;\n }\n if (!headers['content-type'] && blob.type) {\n headers['content-type'] = blob.type;\n }\n const revalidate = typeof context.renderOpts.collectedRevalidate === 'undefined' || context.renderOpts.collectedRevalidate >= INFINITE_CACHE ? false : context.renderOpts.collectedRevalidate;\n const expire = typeof context.renderOpts.collectedExpire === 'undefined' || context.renderOpts.collectedExpire >= INFINITE_CACHE ? undefined : context.renderOpts.collectedExpire;\n // Create the cache entry for the response.\n const cacheEntry = {\n value: {\n kind: CachedRouteKind.APP_ROUTE,\n status: response.status,\n body: Buffer.from(await blob.arrayBuffer()),\n headers\n },\n cacheControl: {\n revalidate,\n expire\n }\n };\n return cacheEntry;\n } else {\n // send response without caching if not ISR\n await sendResponse(nodeNextReq, nodeNextRes, response, context.renderOpts.pendingWaitUntil);\n return null;\n }\n } catch (err) {\n // if this is a background revalidate we need to report\n // the request error here as it won't be bubbled\n if (previousCacheEntry == null ? void 0 : previousCacheEntry.isStale) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: srcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n throw err;\n }\n };\n const cacheEntry = await routeModule.handleResponse({\n req,\n nextConfig,\n cacheKey,\n routeKind: RouteKind.APP_ROUTE,\n isFallback: false,\n prerenderManifest,\n isRoutePPREnabled: false,\n isOnDemandRevalidate,\n revalidateOnlyGenerated,\n responseGenerator,\n waitUntil: ctx.waitUntil,\n isMinimalMode\n });\n // we don't create a cacheEntry for ISR\n if (!isIsr) {\n return null;\n }\n if ((cacheEntry == null ? void 0 : (_cacheEntry_value = cacheEntry.value) == null ? void 0 : _cacheEntry_value.kind) !== CachedRouteKind.APP_ROUTE) {\n var _cacheEntry_value1;\n throw Object.defineProperty(new Error(`Invariant: app-route received invalid cache entry ${cacheEntry == null ? void 0 : (_cacheEntry_value1 = cacheEntry.value) == null ? void 0 : _cacheEntry_value1.kind}`), \"__NEXT_ERROR_CODE\", {\n value: \"E701\",\n enumerable: false,\n configurable: true\n });\n }\n if (!isMinimalMode) {\n res.setHeader('x-nextjs-cache', isOnDemandRevalidate ? 'REVALIDATED' : cacheEntry.isMiss ? 'MISS' : cacheEntry.isStale ? 'STALE' : 'HIT');\n }\n // Draft mode should never be cached\n if (isDraftMode) {\n res.setHeader('Cache-Control', 'private, no-cache, no-store, max-age=0, must-revalidate');\n }\n const headers = fromNodeOutgoingHttpHeaders(cacheEntry.value.headers);\n if (!(isMinimalMode && isIsr)) {\n headers.delete(NEXT_CACHE_TAGS_HEADER);\n }\n // If cache control is already set on the response we don't\n // override it to allow users to customize it via next.config\n if (cacheEntry.cacheControl && !res.getHeader('Cache-Control') && !headers.get('Cache-Control')) {\n headers.set('Cache-Control', getCacheControlHeader(cacheEntry.cacheControl));\n }\n await sendResponse(nodeNextReq, nodeNextRes, // @ts-expect-error - Argument of type 'Buffer<ArrayBufferLike>' is not assignable to parameter of type 'BodyInit | null | undefined'.\n new Response(cacheEntry.value.body, {\n headers,\n status: cacheEntry.value.status || 200\n }));\n return null;\n };\n // TODO: activeSpan code path is for when wrapped by\n // next-server can be removed when this is no longer used\n if (activeSpan) {\n await handleResponse(activeSpan);\n } else {\n await tracer.withPropagatedContext(req.headers, ()=>tracer.trace(BaseServerSpan.handleRequest, {\n spanName: `${method} ${srcPage}`,\n kind: SpanKind.SERVER,\n attributes: {\n 'http.method': method,\n 'http.target': req.url\n }\n }, handleResponse));\n }\n } catch (err) {\n if (!(err instanceof NoFallbackError)) {\n const silenceLog = false;\n await routeModule.onRequestError(req, err, {\n routerKind: 'App Router',\n routePath: normalizedSrcPage,\n routeType: 'route',\n revalidateReason: getRevalidateReason({\n isStaticGeneration,\n isOnDemandRevalidate\n })\n }, silenceLog, routerServerContext);\n }\n // rethrow so that we can handle serving error page\n // If this is during static generation, throw the error again.\n if (isIsr) throw err;\n // Otherwise, send a 500 response.\n await sendResponse(nodeNextReq, nodeNextRes, new Response(null, {\n status: 500\n }));\n return null;\n }\n}\n\n//# sourceMappingURL=app-route.js.map\n"],"names":[],"mappings":"8uCAAA,IAAA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,MAEA,IAAM,EAAY,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,EAAA,IAAI,EAsXnB,EAAiB,IA5W9B,AA4WkC,MA5W5B,AACI,eAAs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