Skip to content

Commit

Permalink
Attach error handler to statsD socket to prevent crashes on connectio…
Browse files Browse the repository at this point in the history
…n problem
  • Loading branch information
TheDeveloper committed Oct 26, 2012
1 parent 41bec96 commit 4222757
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
13 changes: 2 additions & 11 deletions config.js
@@ -1,12 +1,3 @@
var debug = require('debug')('abacus:config');
var config = require('config');

// Check for config module. If not existent, export an empty config
try{
var config = require('config');
debug('Loading config from node-config');
module.exports = config.setModuleDefaults('abacus', require('./config/default'));
}
catch(e){
debug('Setting config to empty object');
module.exports = {};
}
module.exports = config.setModuleDefaults('abacus', require('./config/default'));
2 changes: 1 addition & 1 deletion config/default.js
Expand Up @@ -6,4 +6,4 @@ module.exports = {
},
metricPrefix: 'apps.abacus.'
}
}
};
3 changes: 3 additions & 0 deletions lib/abacus.js
Expand Up @@ -13,6 +13,9 @@ var counters = function(conf){
if(self.config.statsD){
var statsDConfig = self.config.statsD;
self.statsD = new statsD(statsDConfig.connection.host, statsDConfig.connection.port);
self.statsD.socket.on('error', function(e){
return debug('Error on statsD socket: %s', e);
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "abacus",
"version": "0.0.2",
"version": "0.0.3",
"description": "Counter library with statsD support",
"main": "lib/abacus.js",
"scripts": {
Expand Down

0 comments on commit 4222757

Please sign in to comment.