INNER CODE UNIT · TypeScript

shutDown

marcoturi/fastify-boilerplate · src/index.ts:43

  const shutDown = async (signal: string) => {
    fastify.log.info(`Received ${signal}, shutting down gracefully…`);
    await fastify.close();
    await shutdownTelemetry(); // flush buffered spans/metrics before exit
    process.exit(0);
  };
  process.on('SIGTERM', () => shutDown('SIGTERM'));
  process.on('SIGINT', () => shutDown('SIGINT'));

  try {
    await fastify.listen({ port: env.server.port, host: env.server.host });
    fastify.log.info('Server is ready');
  } catch (error) {
    fastify.log.error(error);
    process.exit(1);
  }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…