From 8ad2943ae2448907724711438cbd2920259a0cd4 Mon Sep 17 00:00:00 2001 From: Tyler Montgomery Date: Wed, 9 Dec 2015 15:23:15 -0600 Subject: [PATCH] Adding proper redis queue drainage support, upping redis version and master version --- lib/winston-redis.js | 12 +++++++++--- package.json | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/winston-redis.js b/lib/winston-redis.js index 745942a..ad2aa92 100644 --- a/lib/winston-redis.js +++ b/lib/winston-redis.js @@ -288,6 +288,12 @@ Redis.prototype.stream = function (options) { //Close Connection to redis Server //Winston will call close function from clear/remove to attempt to cleanly exit. Redis.prototype.close = function(){ - if (this.redis) - this.redis.end(); -}; + if (this.redis) { + // Wait for 'drain' event from redis, else we might end the connection before the queue is empt + var rclient = this.redis; + rclient.on("drain", function () { + // Use end(true) to allow internal draining + rclient.end(true); + }); + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 42053ba..8ec7dd3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "winston-redis", "description": "A fixed-length Redis transport for winston", - "version": "1.0.0", + "version": "1.0.1", "author": "Charlie Robbins ", "repository": { "type": "git", @@ -17,7 +17,7 @@ "dependencies": { "async": "^1.2.1", "lodash": "3.10.x", - "redis": "0.12.x" + "redis": "2.4.x" }, "devDependencies": { "winston": "^1.0.0",