ваше сообщение коммита

This commit is contained in:
2025-08-16 22:12:00 +03:00
parent fe0dc6509b
commit 1d636c113f
28 changed files with 6809 additions and 525 deletions

View File

@@ -19,6 +19,7 @@ const { getBot } = require('./services/telegramBot');
const EmailBotService = require('./services/emailBot');
const { initDbPool, seedAIAssistantSettings } = require('./db');
const { warmupModel } = require('./scripts/warmup-model'); // Добавляем импорт разогрева модели
const memoryMonitor = require('./utils/memoryMonitor');
const PORT = process.env.PORT || 8000;
@@ -98,4 +99,25 @@ process.on('uncaughtException', (err) => {
logger.error('Uncaught Exception:', err);
});
// Запускаем мониторинг памяти в production
if (process.env.NODE_ENV === 'production') {
memoryMonitor.start(300000); // Каждые 5 минут
logger.info('[Server] Мониторинг памяти запущен в production режиме');
}
// Обработчики для корректного завершения
process.on('SIGINT', async () => {
logger.info('[Server] Получен сигнал SIGINT, завершаем работу...');
memoryMonitor.stop();
await initDbPool().then(pool => pool.end()); // Use initDbPool to get the pool
process.exit(0);
});
process.on('SIGTERM', async () => {
logger.info('[Server] Получен сигнал SIGTERM, завершаем работу...');
memoryMonitor.stop();
await initDbPool().then(pool => pool.end()); // Use initDbPool to get the pool
process.exit(0);
});
module.exports = app;