From c9df7787d560dd1bd910dd6a91edac9dd083eb51 Mon Sep 17 00:00:00 2001 From: Ace Date: Fri, 26 Jun 2026 11:10:58 +0200 Subject: [PATCH] Added in loading bot --- ai-server/index.mjs | 36 ++++ package.json | 3 +- splash.html | 453 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 491 insertions(+), 1 deletion(-) create mode 100644 splash.html diff --git a/ai-server/index.mjs b/ai-server/index.mjs index cd605d7..726c577 100644 --- a/ai-server/index.mjs +++ b/ai-server/index.mjs @@ -256,11 +256,47 @@ const server = http.createServer(async (req, res) => { const { pathname } = parseURL(req) try { + // GET /splash — loading screen + if (req.method === "GET" && pathname === "/splash") { + const splashPath = path.join(ROOT, "splash.html") + if (fs.existsSync(splashPath)) { + const html = fs.readFileSync(splashPath, "utf-8") + res.writeHead(200, { "Content-Type": "text/html" }) + res.end(html) + return + } + sendJSON(res, 200, { status: "ok" }) + return + } + // GET /health if (req.method === "GET" && pathname === "/health") { return sendJSON(res, 200, { status: "ok", model: MODEL }) } + // GET /status — combined health of all services + if (req.method === "GET" && pathname === "/status") { + const { default: http } = await import("http") + const results = { ai: true } + // Check scraper + try { + await new Promise((resolve, reject) => { + 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 + 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 + } catch { results.frontend = false } + return sendJSON(res, 200, results) + } + // GET /ai/jobs if (req.method === "GET" && pathname === "/ai/jobs") { return sendJSON(res, 200, { jobs: loadedJobs }) diff --git a/package.json b/package.json index 3bd629f..2e0a228 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "dev": "npm run dev:precheck & npm run dev:ollama & npm run dev:start", "dev:signaling": "node signaling-server.mjs", - "dev:start": "concurrently -n AI,BROWSE,SIGNAL,NEXT -c cyan,magenta,yellow,green \"npm run dev:rust\" \"npm run dev:browser-use\" \"npm run dev:signaling\" \"npm run dev:next\"", + "dev:open": "powershell -NoProfile -Command \"Start-Sleep 8; Start-Process 'http://localhost:3001/splash'\"", + "dev:start": "concurrently -n AI,BROWSE,SIGNAL,NEXT,OPEN -c cyan,magenta,yellow,green,white \"npm run dev:rust\" \"npm run dev:browser-use\" \"npm run dev:signaling\" \"npm run dev:next\" \"npm run dev:open\"", "dev:next": "next dev -p 3006", "dev:precheck": "powershell -NoProfile -Command \"Get-NetTCPConnection -State Listen | Where-Object { $_.LocalPort -in 3001,3006,3007,3008 } | ForEach-Object { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue; Write-Host ('Freed port '+$_.LocalPort) }\"", "dev:ollama": "powershell -NoProfile -Command \"$ollama = if (Get-Command ollama -ErrorAction SilentlyContinue) { 'ollama' } else { Join-Path $env:LOCALAPPDATA 'Programs\\Ollama\\ollama.exe' }; if (-not (Get-Process ollama -ErrorAction SilentlyContinue)) { Start-Process $ollama -ArgumentList 'serve' -WindowStyle Hidden; Start-Sleep 3 }; exit 0\"", diff --git a/splash.html b/splash.html new file mode 100644 index 0000000..367dfce --- /dev/null +++ b/splash.html @@ -0,0 +1,453 @@ + + + + + +Loading CoastIT CRM + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+
+ AI Server +
+
+
+
+
+ waiting... +
+
+ Scraper +
+
+
+
+
+ waiting... +
+
+ Frontend +
+
+
+
+
+ waiting... +
+
+ +
Loading...
+ + +
+
+
🚀 Launching gear!
+
+ +
+ + + + + \ No newline at end of file