buildApp() returns the configured Fastify instance without listening, so tests can drive it with inject(). Shutdown of database, Redis and queue connections now lives in one place shared by the server and worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
16 lines
366 B
TypeScript
16 lines
366 B
TypeScript
import { buildApp } from './app';
|
|
import { closeConnections } from './lib/lifecycle';
|
|
import { env } from './env';
|
|
|
|
const app = await buildApp();
|
|
|
|
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
process.on(signal, async () => {
|
|
await app.close();
|
|
await closeConnections();
|
|
process.exit(0);
|
|
});
|
|
}
|
|
|
|
await app.listen({ port: env.PORT, host: '0.0.0.0' });
|