Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

fix: options missing when called storage backend #630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/persistence/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,24 @@ util.inherits(RedisPersistence, AbstractPersistence);
RedisPersistence.prototype._buildClient = function() {
var options = this.options.redisOptions || {};

if (this.options.url) {
options.url = this.options.url;
if (this.options.backend.url) {
options.url = this.options.backend.url;
}
if (this.options.host) {
options.host = this.options.host;

if (this.options.backend.host) {
options.host = this.options.backend.host;
}

if (this.options.port) {
options.port = this.options.port;
if (this.options.backend.port) {
options.port = this.options.backend.port;
}

if (this.options.db) {
options.db = this.options.db;
if (this.options.backend.db) {
options.db = this.options.backend.db;
}

if (this.options.password) {
options.password = this.options.password;
if (this.options.backend.password) {
options.password = this.options.backend.password;
}

return new Redis(options);
Expand Down
5 changes: 4 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ function Server(opts, callback) {
}
}

// make sure storage backend get options
that.modernOpts.persistence.backend = opts.backend

that.persistence = persistenceFactory(that.modernOpts.persistence, done);
that.persistence.wire(that);
} else {
Expand Down Expand Up @@ -618,7 +621,7 @@ Server.prototype.attachHttpServer = function(server, path) {
if (path) {
opt.path = path;
}

ws.createServer(opt, function(stream) {
var conn = new Connection(stream);
new Client(conn, that);
Expand Down