Skip to content

Commit

Permalink
Merge pull request #27 from thurmda/master
Browse files Browse the repository at this point in the history
Converted config to a module
  • Loading branch information
mnutt committed Jun 16, 2011
2 parents 67d809c + ad879d7 commit 9e2750b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
19 changes: 19 additions & 0 deletions config/config.js
@@ -0,0 +1,19 @@
module.exports = config = {
"name" : "Hummingbird",

"tracking_port" : 8000,
"dashboard_port" : 8080,

"mongo_host" : "localhost",
"mongo_port" : 27017,

"udp_address" : "127.0.0.1",
"udp_port" : 8000,

"enable_dashboard" : true,

"capistrano" : {
"repository" : "git://github.com/mnutt/hummingbird.git",
"hummingbird_host" : "hummingbird.your-host.com"
}
}
7 changes: 1 addition & 6 deletions lib/hummingbird.js
@@ -1,5 +1,6 @@
var sys = require('sys'),
fs = require('fs'),
config = require('../config/config'),
View = require('view').View,
Metric = require('metric').Metric,
Aggregates = require('aggregates').Aggregates,
Expand All @@ -8,12 +9,6 @@ var sys = require('sys'),
arrays = require('deps/arrays'),
querystring = require('querystring');

try {
var configJSON = fs.readFileSync(__dirname + "/../config/app.json");
} catch(e) {
sys.log("File config/app.json not found. Try: `cp config/app.json.sample config/app.json`");
}
var config = JSON.parse(configJSON.toString());

var Hummingbird = function(db, callback) {
var pixelData = fs.readFileSync(__dirname + "/../images/tracking.gif", 'binary');
Expand Down
9 changes: 1 addition & 8 deletions server.js
Expand Up @@ -3,20 +3,13 @@ require.paths.unshift(__dirname);

var http = require('http'),
weekly = require('weekly'),
fs = require('fs'),
config = require('./config/config'),
dgram = require('dgram'),
static = require('node-static'),
io = require('socket.io'),
mongo = require('mongodb'),
Hummingbird = require('hummingbird').Hummingbird;

try {
var configJSON = fs.readFileSync(__dirname + "/config/app.json");
} catch(e) {
console.log("File config/app.json not found. Try: `cp config/app.json.sample config/app.json`");
}
var config = JSON.parse(configJSON.toString());

db = new mongo.Db('hummingbird', new mongo.Server(config.mongo_host, config.mongo_port, {}), {});

db.addListener("error", function(error) {
Expand Down

0 comments on commit 9e2750b

Please sign in to comment.