Permalink
Browse files

Adding the heroku stuff

  • Loading branch information...
1 parent 3a6ef2c commit 4508f5d310b690e617c131429e6ad91e7e33177d Kirsten Jones committed Jan 6, 2012
Showing with 20 additions and 2 deletions.
  1. +1 −0 Procfile
  2. +19 −2 app.js
View
@@ -0,0 +1 @@
+web: node web.js
View
21 app.js
@@ -49,8 +49,16 @@ try {
// Redis connection
//
var defaultDB = '0';
-var db = redis.createClient(config.redis.port, config.redis.host);
-db.auth(config.redis.password);
+var db;
+
+if (process.env.REDISTOGO_URL) {
+ var rtg = require("url").parse(process.env.REDISTOGO_URL);
+ db = require("redis").createClient(rtg.port, rtg.hostname);
+ db.auth(rtg.auth.split(":")[1]);
+} else {
+ db = redis.createClient(config.redis.port, config.redis.host);
+ db.auth(config.redis.password);
+}
// Select our DB
db.on("connect", function() {
@@ -83,6 +91,15 @@ fs.readFile('public/data/apiconfig.json', 'utf-8', function(err, data) {
var app = module.exports = express.createServer();
app.configure(function() {
+ // CORE UPDATE:
+ if (process.env.REDISTOGO_URL) {
+ // use production (Heroku) redis configuration
+ // overwrite `config` to keep it simple
+ var rtg = require(‘url’).parse(process.env.REDISTOGO_URL);
+ config.redis.port = rtg.port;
+ config.redis.host = rtg.hostname;
+ config.redis.password = rtg.auth.split(“:”)[1];
+ }
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.logger());

0 comments on commit 4508f5d

Please sign in to comment.