34 lines
660 B
JavaScript
34 lines
660 B
JavaScript
#!/usr/bin/env node
|
|
|
|
const http = require('http');
|
|
|
|
const options = {
|
|
host: 'localhost',
|
|
port: process.env.BACKEND_PORT || 3001,
|
|
path: '/health',
|
|
timeout: 2000,
|
|
method: 'GET'
|
|
};
|
|
|
|
const req = http.request(options, (res) => {
|
|
if (res.statusCode === 200) {
|
|
console.log('Health check passed');
|
|
process.exit(0);
|
|
} else {
|
|
console.log(`Health check failed with status: ${res.statusCode}`);
|
|
process.exit(1);
|
|
}
|
|
});
|
|
|
|
req.on('error', (err) => {
|
|
console.log(`Health check failed: ${err.message}`);
|
|
process.exit(1);
|
|
});
|
|
|
|
req.on('timeout', () => {
|
|
console.log('Health check timeout');
|
|
req.destroy();
|
|
process.exit(1);
|
|
});
|
|
|
|
req.end(); |