From e4b3d0ec97ded2658543e02a61896a50d65b6944 Mon Sep 17 00:00:00 2001 From: Jeff Minard Date: Wed, 4 May 2011 01:54:18 +0800 Subject: [PATCH] Adding even BETTER error handling that catches ECONREFUSED when carbon it totally offline --- stats.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/stats.js b/stats.js index 97a5ce12..f76d1738 100644 --- a/stats.js +++ b/stats.js @@ -121,12 +121,19 @@ config.configFile(process.argv[2], function (config, oldConfig) { try { var graphite = net.createConnection(config.graphitePort, config.graphiteHost); + graphite.addListener('error', function(connectionException){ + if (config.debug) { + sys.log(connectionException); + } + }); graphite.on('connect', function() { this.write(statString); this.end(); }); } catch(e){ - // no big deal + if (config.debug) { + sys.log(e); + } } }, flushInterval);