Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisCloud config support, Redis settings for session store fixed #11

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
15 changes: 6 additions & 9 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ derby.use(require('racer-bundle'));
exports.setup = setup;

function setup(app, options, cb) {
var redisClient;
var redisClient, redisUrlConfig = process.env.OPENREDIS_URL || process.env.REDISCLOUD_URL;
if (process.env.REDIS_HOST) {
redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST);
redisClient.auth(process.env.REDIS_PASSWORD);
} else if (process.env.OPENREDIS_URL) {
var redisUrl = parseUrl(process.env.OPENREDIS_URL);
} else if (redisUrlConfig) {
var redisUrl = parseUrl(redisUrlConfig);
redisClient = redis.createClient(redisUrl.port, redisUrl.hostname);
redisClient.auth(redisUrl.auth.split(":")[1]);
} else {
Expand All @@ -31,8 +31,8 @@ function setup(app, options, cb) {
}
// The store creates models and syncs data
var store = derby.createStore({
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true})
, redis: redisClient
db: liveDbMongo(mongoUrl + '?auto_reconnect', {safe: true}),
redis: redisClient
});

store.on('bundle', function(browserify) {
Expand Down Expand Up @@ -68,10 +68,7 @@ function setup(app, options, cb) {
.use(express.cookieParser())
.use(express.session({
secret: process.env.SESSION_SECRET || 'YOUR SECRET HERE'
, store: new RedisStore({
host: process.env.REDIS_HOST || "localhost",
port: process.env.REDIS_PORT || 6379
})
, store: new RedisStore({client:redisClient})
}))
.use(handlers.middleware)
.use(createUserId)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "derby-starter",
"version": "0.2.3",
"version": "0.2.4",
"description": "A generic server for a simple Derby app",
"main": "lib/index.js",
"repository": {
Expand Down