feat: Initial commit of PDF Tools project
This commit is contained in:
35
server/healthcheck.js
Normal file
35
server/healthcheck.js
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const http = require('http');
|
||||
const process = require('process');
|
||||
|
||||
const options = {
|
||||
hostname: 'localhost',
|
||||
port: process.env.PORT || 3001,
|
||||
path: '/health',
|
||||
method: 'GET',
|
||||
timeout: 3000,
|
||||
};
|
||||
|
||||
const healthCheck = http.request(options, (res) => {
|
||||
console.log(`Health check status: ${res.statusCode}`);
|
||||
|
||||
if (res.statusCode === 200) {
|
||||
process.exit(0);
|
||||
} else {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
healthCheck.on('error', (err) => {
|
||||
console.error('Health check failed:', err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
healthCheck.on('timeout', () => {
|
||||
console.error('Health check timeout');
|
||||
healthCheck.destroy();
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
healthCheck.end();
|
||||
Reference in New Issue
Block a user