add smart random

This commit is contained in:
2023-07-14 14:54:47 +02:00
parent 68942e904f
commit b14fb39009
25 changed files with 509 additions and 104 deletions

View File

@@ -29,10 +29,16 @@ export class PrismaService extends PrismaClient implements OnModuleInit {
async onModuleInit() {
await this.$connect()
}
async enableShutdownHooks(app: INestApplication) {
this.$on('beforeExit', async () => {
private exitHandler(app: INestApplication) {
return async () => {
await app.close()
})
}
}
async enableShutdownHooks(app: INestApplication) {
process.on('exit', this.exitHandler(app))
process.on('beforeExit', this.exitHandler(app))
process.on('SIGINT', this.exitHandler(app))
process.on('SIGTERM', this.exitHandler(app))
process.on('SIGUSR2', this.exitHandler(app))
}
}