Removes un-necessary shutdown handler (#3786)

* Removes un-necessary shutdown handler

- When registering a shutdown hander, the node process has to be exited manually which causes issues for many users

* Proper graceful shutdown from CLI
This commit is contained in:
Florent Vilmart
2017-05-08 13:06:01 -04:00
committed by Arthur Cinader
parent 864d191d0c
commit 8d67776c2e
3 changed files with 18 additions and 14 deletions

View File

@@ -97,17 +97,6 @@ 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() {
@@ -139,6 +128,13 @@ export class MongoStorageAdapter {
return this.connectionPromise;
}
handleShutdown() {
if (!this.database) {
return;
}
this.database.close(false);
}
_adaptiveCollection(name: string) {
return this.connect()
.then(() => this.database.collection(this._collectionPrefix + name))