Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import { buildApp } from './infrastructure/http/build-app';
import { env } from './shared/config/env';
import { logger } from './shared/logging/logger';
import { prisma } from './infrastructure/database/prisma-client';
import { redis } from './infrastructure/cache/redis-client';
import {
reminderDeadLetterQueue,
reminderQueue,
scheduleDailyReminderJob,
} from './infrastructure/queue/reminder-queue';
import { createReminderWorker } from './infrastructure/queue/reminder-worker';
import { demoAccountQueue, scheduleDemoAccountSweep } from './infrastructure/queue/demo-account-queue';
import { createDemoAccountWorker } from './infrastructure/queue/demo-account-worker';
async function start() {
const app = await buildApp();
const reminderWorker = createReminderWorker();
await scheduleDailyReminderJob();
const demoAccountWorker = createDemoAccountWorker();
await scheduleDemoAccountSweep();
const shutdown = async (signal: string) => {
logger.info({ signal }, 'server.shutting_down');
await app.close();
await reminderWorker.close();
await reminderQueue.close();
await reminderDeadLetterQueue.close();
await demoAccountWorker.close();
await demoAccountQueue.close();
await prisma.$disconnect();
await redis.quit();
process.exit(0);
};
process.on('SIGINT', () => void shutdown('SIGINT'));
process.on('SIGTERM', () => void shutdown('SIGTERM'));
try {
await app.listen({ port: env.PORT, host: env.HOST });
logger.info('reminders.worker_started');
} catch (error) {
logger.error({ err: error }, 'server.failed_to_start');
process.exit(1);
}
}
void start();
|