Nestjs Shutdown hooks
This tutorial explains about NestJS Shutdown Hooks and
Every Component Such as Application, Module etc has life cycle hooks to listen events and write a custom code.
This tutorials shows you multiple ways about shutown hooks in NestJS
NestJS Shutdown Hooks
onApplicationShutdown
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Starts listening for shutdown hooks
app.enableShutdownHooks();
await app.listen(3000);
}