Skip to content

Commit

Permalink
Don't delete subscription if fanout is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvel Mathew committed Sep 18, 2017
1 parent 1804860 commit ca24ea1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,18 @@ class Subscriber extends events.EventEmitter {
function removeListeners() {
subscription.removeListener('message', onMessage);
subscription.removeListener('error', onError);
process.removeListener('SIGTERM', deleteSubscription);
process.removeListener('SIGINT', deleteSubscription);

if (!this.disableFanOut) {
process.removeListener('SIGTERM', deleteSubscription);
process.removeListener('SIGINT', deleteSubscription);
}
}

// Handle termination, delete the subscription (require graceful shutdowm)
process.on('SIGTERM', deleteSubscription);
process.on('SIGINT', deleteSubscription);
if (!this.disableFanOut) {
process.on('SIGTERM', deleteSubscription);
process.on('SIGINT', deleteSubscription);
}

// Bind the subscription
subscription.on('message', onMessage);
Expand Down

0 comments on commit ca24ea1

Please sign in to comment.