From cc8ee63639d90a9da2c82f765083ec623e03a70b Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Wed, 20 May 2026 22:59:03 -0400 Subject: [PATCH] =?UTF-8?q?fix(node-agent):=20replace=20express=20with=20b?= =?UTF-8?q?uilt-in=20http=20=E2=80=94=20no=20external=20deps=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/node-agent/index.js | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/services/node-agent/index.js b/services/node-agent/index.js index 79a8dc1..425ac3e 100644 --- a/services/node-agent/index.js +++ b/services/node-agent/index.js @@ -1,6 +1,6 @@ -import express from 'express'; -import os from 'os'; -import fs from 'fs'; +import http from 'http'; +import os from 'os'; +import fs from 'fs'; const MAM_API_URL = (process.env.MAM_API_URL || 'http://localhost:3000').replace(/\/$/, ''); const NODE_TOKEN = process.env.NODE_TOKEN || ''; @@ -9,18 +9,20 @@ const AGENT_PORT = parseInt(process.env.AGENT_PORT || '3002', 10); const HEARTBEAT_MS = parseInt(process.env.HEARTBEAT_MS || '30000', 10); const VERSION = '1.0.0'; -const app = express(); -app.use(express.json()); - -// ── Health ──────────────────────────────────────────────────────────────── -app.get('/health', (_req, res) => { - res.json({ - ok: true, - hostname: os.hostname(), - uptime: Math.round(process.uptime()), - version: VERSION, - role: NODE_ROLE, - }); +const server = http.createServer((req, res) => { + if (req.method === 'GET' && req.url === '/health') { + res.writeHead(200, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ + ok: true, + hostname: os.hostname(), + uptime: Math.round(process.uptime()), + version: VERSION, + role: NODE_ROLE, + })); + } else { + res.writeHead(404); + res.end(); + } }); // ── CPU sampling (500ms window) ─────────────────────────────────────────── @@ -51,8 +53,7 @@ function getIp() { } // ── Hardware detection ──────────────────────────────────────────────────── -// GPU_COUNT env var overrides filesystem detection (useful when /dev not mapped into container) -// BMD_COUNT env var similarly overrides Blackmagic DeckLink detection +// GPU_COUNT / BMD_COUNT env vars override filesystem detection when /dev isn't mapped function detectHardware() { const capabilities = { gpus: [], blackmagic: [] }; @@ -134,7 +135,7 @@ async function heartbeat() { heartbeat(); setInterval(heartbeat, HEARTBEAT_MS); -app.listen(AGENT_PORT, () => { +server.listen(AGENT_PORT, () => { console.log(`wild-dragon-node-agent v${VERSION}`); console.log(` Listening :${AGENT_PORT}`); console.log(` Primary ${MAM_API_URL}`);