From cd67421c5f329513b06652642468034dc93e0536 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Fri, 30 Jan 2026 05:00:03 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20path=20parameter=20to=20he?= =?UTF-8?q?althCheck=20function=20and=20update=20backend=20health=20check?= =?UTF-8?q?=20calls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/utils/deploy-pokedex.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/utils/deploy-pokedex.js b/code/utils/deploy-pokedex.js index f228623..71b23f1 100644 --- a/code/utils/deploy-pokedex.js +++ b/code/utils/deploy-pokedex.js @@ -162,15 +162,16 @@ function createModifiedDockerCompose(port, sslPort, backendPort) { * Perform HTTP health check * @param {string} host - Host to check * @param {number} port - Port to check + * @param {string} path - Path to check (default: /) * @param {number} retries - Number of retries * @returns {Promise} True if healthy */ -async function healthCheck(host, port, retries = 5) { +async function healthCheck(host, port, path = '/', retries = 5) { for (let i = 0; i < retries; i++) { try { await new Promise((resolve, reject) => { const req = http.get( - `http://${host}:${port}`, + `http://${host}:${port}${path}`, { timeout: 5000 }, res => { if (res.statusCode === 200) { @@ -250,7 +251,7 @@ async function deployLocal(config) { if (!frontendHealthy) throw new Error('Frontend health check failed'); console.log(' ✅ Frontend healthy'); - console.log(' Checking backend...'); + const backendHealthy = await healthCheck('localhost', config.backendPort, '/health'); const backendHealthy = await healthCheck('localhost', config.backendPort); // Backend might need more time if (!backendHealthy) throw new Error('Backend health check failed'); @@ -624,7 +625,8 @@ async function deploy() { console.log(' Checking backend...'); const backendHealthy = await healthCheck( sshConfig.host, - config.backendPort + config.backendPort, + '/health' ); if (!backendHealthy) { throw new Error(