Fix splash page /status endpoint for removed scraper service
Build & Auto-Repair / build (push) Has been cancelled
Build & Auto-Repair / build (push) Has been cancelled
- Remove scraper health check (port 3008) since dev:browser-use was removed from dev:start; always report scraper as ready - Add checkPort helper with localhost fallback for frontend check to handle Windows IPv6/IPv4 resolution issues
This commit is contained in:
+20
-17
@@ -269,6 +269,13 @@ function parseBody(req) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkPort(http, host, port, timeout) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const r = http.get(`http://${host}:${port}`, { timeout }, (res) => { res.resume(); resolve() })
|
||||||
|
r.on("error", reject)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function parseURL(req) {
|
function parseURL(req) {
|
||||||
const url = new URL(req.url, `http://${req.headers.host || "localhost"}`)
|
const url = new URL(req.url, `http://${req.headers.host || "localhost"}`)
|
||||||
return { pathname: url.pathname, searchParams: url.searchParams }
|
return { pathname: url.pathname, searchParams: url.searchParams }
|
||||||
@@ -309,27 +316,23 @@ const server = http.createServer(async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET /status — combined health of all services
|
// GET /status — combined health of all services
|
||||||
// Used by the splash page to check if AI, Scraper, and Frontend are ready.
|
// Used by the splash page to check if AI and Frontend are ready.
|
||||||
// Polls each service internally to avoid cross-origin CORS issues.
|
// Scraper is no longer part of dev:start so it's always reported ready.
|
||||||
if (req.method === "GET" && pathname === "/status") {
|
if (req.method === "GET" && pathname === "/status") {
|
||||||
const { default: http } = await import("http")
|
const { default: http } = await import("http")
|
||||||
const results = { ai: true }
|
const results = { ai: true, scraper: true }
|
||||||
// Check scraper (port 3008)
|
// Check frontend (port 3006) — try localhost, fallback to 127.0.0.1
|
||||||
try {
|
try {
|
||||||
await new Promise((resolve, reject) => {
|
await checkPort(http, "localhost", 3006, 2000)
|
||||||
const r = http.get("http://127.0.0.1:3008/health", { timeout: 3000 }, (res) => { res.resume(); resolve() })
|
|
||||||
r.on("error", reject)
|
|
||||||
})
|
|
||||||
results.scraper = true
|
|
||||||
} catch { results.scraper = false }
|
|
||||||
// Check frontend (port 3006)
|
|
||||||
try {
|
|
||||||
await new Promise((resolve, reject) => {
|
|
||||||
const r = http.get("http://127.0.0.1:3006", { timeout: 3000 }, (res) => { res.resume(); resolve() })
|
|
||||||
r.on("error", reject)
|
|
||||||
})
|
|
||||||
results.frontend = true
|
results.frontend = true
|
||||||
} catch { results.frontend = false }
|
} catch {
|
||||||
|
try {
|
||||||
|
await checkPort(http, "127.0.0.1", 3006, 2000)
|
||||||
|
results.frontend = true
|
||||||
|
} catch {
|
||||||
|
results.frontend = false
|
||||||
|
}
|
||||||
|
}
|
||||||
return sendJSON(res, 200, results)
|
return sendJSON(res, 200, results)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user