🔧 Add path parameter to healthCheck function and update backend health check calls
This commit is contained in:
@@ -162,15 +162,16 @@ function createModifiedDockerCompose(port, sslPort, backendPort) {
|
|||||||
* Perform HTTP health check
|
* Perform HTTP health check
|
||||||
* @param {string} host - Host to check
|
* @param {string} host - Host to check
|
||||||
* @param {number} port - Port to check
|
* @param {number} port - Port to check
|
||||||
|
* @param {string} path - Path to check (default: /)
|
||||||
* @param {number} retries - Number of retries
|
* @param {number} retries - Number of retries
|
||||||
* @returns {Promise<boolean>} True if healthy
|
* @returns {Promise<boolean>} 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++) {
|
for (let i = 0; i < retries; i++) {
|
||||||
try {
|
try {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const req = http.get(
|
const req = http.get(
|
||||||
`http://${host}:${port}`,
|
`http://${host}:${port}${path}`,
|
||||||
{ timeout: 5000 },
|
{ timeout: 5000 },
|
||||||
res => {
|
res => {
|
||||||
if (res.statusCode === 200) {
|
if (res.statusCode === 200) {
|
||||||
@@ -250,7 +251,7 @@ async function deployLocal(config) {
|
|||||||
if (!frontendHealthy) throw new Error('Frontend health check failed');
|
if (!frontendHealthy) throw new Error('Frontend health check failed');
|
||||||
console.log(' ✅ Frontend healthy');
|
console.log(' ✅ Frontend healthy');
|
||||||
|
|
||||||
console.log(' Checking backend...');
|
const backendHealthy = await healthCheck('localhost', config.backendPort, '/health');
|
||||||
const backendHealthy = await healthCheck('localhost', config.backendPort);
|
const backendHealthy = await healthCheck('localhost', config.backendPort);
|
||||||
// Backend might need more time
|
// Backend might need more time
|
||||||
if (!backendHealthy) throw new Error('Backend health check failed');
|
if (!backendHealthy) throw new Error('Backend health check failed');
|
||||||
@@ -624,7 +625,8 @@ async function deploy() {
|
|||||||
console.log(' Checking backend...');
|
console.log(' Checking backend...');
|
||||||
const backendHealthy = await healthCheck(
|
const backendHealthy = await healthCheck(
|
||||||
sshConfig.host,
|
sshConfig.host,
|
||||||
config.backendPort
|
config.backendPort,
|
||||||
|
'/health'
|
||||||
);
|
);
|
||||||
if (!backendHealthy) {
|
if (!backendHealthy) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user