Skip to content

Instantly share code, notes, and snippets.

@mark-b-ab
Created March 8, 2022 17:42
Show Gist options
  • Save mark-b-ab/8f74919944d5dac9330ff864a7ed9f6f to your computer and use it in GitHub Desktop.
Save mark-b-ab/8f74919944d5dac9330ff864a7ed9f6f to your computer and use it in GitHub Desktop.
import { Module, OnApplicationShutdown, OnModuleDestroy } from '@nestjs/common';
import { setTimeout } from 'timers/promises';
@Module({})
export class AppModule implements OnModuleDestroy, OnApplicationShutdown {
async onApplicationShutdown(signal?: string) {
console.log('onApplicationShutdown', signal);
}
async onModuleDestroy() {
console.log('onModuleDestroy before wait');
await setTimeout(2000);
console.log('onModuleDestroy after wait');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment