health check
This commit is contained in:
@@ -4,6 +4,9 @@ FROM node:18-slim
|
|||||||
# Create app directory
|
# Create app directory
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
# Install curl for healthcheck
|
||||||
|
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install app dependencies
|
# Install app dependencies
|
||||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|||||||
20
index.js
20
index.js
@@ -1,8 +1,12 @@
|
|||||||
const winston = require('winston');
|
const winston = require('winston');
|
||||||
|
const express = require('express');
|
||||||
const { createClient } = require('@supabase/supabase-js');
|
const { createClient } = require('@supabase/supabase-js');
|
||||||
const Bot = require('./src/Bot');
|
const Bot = require('./src/Bot');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
|
// Initialize Express app
|
||||||
|
const app = express();
|
||||||
|
|
||||||
// Initialize logger
|
// Initialize logger
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
level: 'debug',
|
level: 'debug',
|
||||||
@@ -26,6 +30,17 @@ const supabase = createClient(
|
|||||||
process.env.SUPABASE_KEY
|
process.env.SUPABASE_KEY
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add health check endpoint
|
||||||
|
app.get('/health', (req, res) => {
|
||||||
|
res.status(200).json({ status: 'healthy' });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start Express server
|
||||||
|
const port = process.env.NOTIFICATION_PORT || 3000;
|
||||||
|
app.listen(port, () => {
|
||||||
|
logger.info(`Health check server listening on port ${port}`);
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize and start bot
|
// Initialize and start bot
|
||||||
const bot = new Bot(process.env.DISCORD_TOKEN, supabase, logger);
|
const bot = new Bot(process.env.DISCORD_TOKEN, supabase, logger);
|
||||||
bot.start().catch(error => {
|
bot.start().catch(error => {
|
||||||
@@ -54,9 +69,4 @@ process.on('SIGTERM', async () => {
|
|||||||
console.error('Error during shutdown:', error);
|
console.error('Error during shutdown:', error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Add health check endpoint
|
|
||||||
app.get('/health', (req, res) => {
|
|
||||||
res.status(200).json({ status: 'healthy' });
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user