Adds graceful shutdown handler for mongodb (#3706)

This commit is contained in:
Florent Vilmart
2017-04-11 12:26:25 -04:00
committed by Arthur Cinader
parent 906fb27389
commit e7a45cecb7

View File

@@ -97,6 +97,17 @@ export class MongoStorageAdapter {
// MaxTimeMS is not a global MongoDB client option, it is applied per operation.
this._maxTimeMS = mongoOptions.maxTimeMS;
process.on('SIGTERM', this.handleShutdown(this));
process.on('SIGINT', this.handleShutdown(this));
}
handleShutdown(storageAdapter) {
return () => {
if (!storageAdapter.database) {
return;
}
storageAdapter.database.close(false);
}
}
connect() {