From 57da28f65c82496f5e5ac97a64049093ca5fea2d Mon Sep 17 00:00:00 2001 From: guanzhongcai <1067716332@qq.com> Date: Tue, 14 Jan 2020 14:01:03 +0800 Subject: [PATCH 1/2] add redis db select --- lib/manager/statusManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/manager/statusManager.js b/lib/manager/statusManager.js index 492a2ae..b91a838 100644 --- a/lib/manager/statusManager.js +++ b/lib/manager/statusManager.js @@ -19,6 +19,12 @@ StatusManager.prototype.start = function(cb) { if (this.opts.auth_pass) { this.redis.auth(this.opts.auth_pass); } + var db = this.opts.db || 0; + this.redis.select(db, function (err) { + if (!!err) { + console.error("[status-plugin][redis]" + err.stack); + } + }); this.redis.on("error", function (err) { console.error("[status-plugin][redis]" + err.stack); }); From cae89372b75d221de51b898240ee0f69ebeb3524 Mon Sep 17 00:00:00 2001 From: guanzhongcai <1067716332@qq.com> Date: Tue, 14 Jan 2020 14:03:32 +0800 Subject: [PATCH 2/2] update readme.md for redis db select --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a87a7c4..6008add 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ var status = require('pomelo-status-plugin'); app.use(status, {status: { host: '127.0.0.1', - port: 6379 + port: 6379, + db: 1, }}); ``` @@ -75,6 +76,7 @@ var mysqlStatusManager = require('./mysqlStatusManager'); app.use(status, {status: { host: '127.0.0.1', port: 6379, + db: 1, channelManager: mysqlStatusManager }}); @@ -85,6 +87,7 @@ in >=0.0.3 version add cleanOnStartUp option, when you enable this option, statu app.use(status, {status: { host: '127.0.0.1', port: 6379, + db: 1, cleanOnStartUp: true }});