Skip to content

Commit

Permalink
Fixing app.js to allow for heroku. Also adding config.json for heroku…
Browse files Browse the repository at this point in the history
… test (will remove after)
  • Loading branch information
synedra committed Jan 6, 2012
1 parent be8b9e6 commit 321358c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
27 changes: 13 additions & 14 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@ try {
// Redis connection
//
var defaultDB = '0';
var db = redis.createClient(config.redis.port, config.redis.host);
db.auth(config.redis.password);

// Select our DB
db.on("connect", function() {
db.select(defaultDB);
db.get("livedocs", function(err, reply) {
if (config.debug) {
console.log('Selected db \''+ defaultDB + '\' named \'' + reply + '\'');
}
});
});
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);
}

db.on("error", function(err) {
if (config.debug) {
Expand Down Expand Up @@ -651,6 +649,7 @@ app.get('/:api([^\.]+)', function(req, res) {
// Only listen on $ node app.js

if (!module.parent) {
app.listen(config.port, config.address);
var port = process.env.PORT || config.port;
app.listen(port);
console.log("Express server listening on port %d", app.address().port);
}
}
12 changes: 12 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"title" : "I/O Docs - http://github.com/mashery/iodocs",
"port" : 3000,
"debug" : true,
"sessionSecret" : "12345",
"redis" : {
"host" : "localhost",
"port" : 6379,
"password" : "",
"database" : "0"
}
}

0 comments on commit 321358c

Please sign in to comment.