Create Transcriber service health check
This commit is contained in:
29
services/transcriber/src/healthcheck.js
Normal file
29
services/transcriber/src/healthcheck.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { createClient } from 'redis';
|
||||
import { Client as PgClient } from 'pg';
|
||||
|
||||
const POSTGRES_URL = process.env.POSTGRES_URL;
|
||||
const REDIS_URL = process.env.REDIS_URL || 'redis://redis:6379';
|
||||
|
||||
async function healthCheck() {
|
||||
try {
|
||||
// Test PostgreSQL connection
|
||||
const pgClient = new PgClient({ connectionString: POSTGRES_URL });
|
||||
await pgClient.connect();
|
||||
await pgClient.query('SELECT 1');
|
||||
await pgClient.end();
|
||||
|
||||
// Test Redis connection
|
||||
const redisClient = createClient({ url: REDIS_URL });
|
||||
await redisClient.connect();
|
||||
await redisClient.ping();
|
||||
await redisClient.quit();
|
||||
|
||||
console.log('Health check passed');
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('Health check failed:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
healthCheck();
|
Reference in New Issue
Block a user