Permalink
Browse files

fixed a reconnect bug in the graphite_axon

  • Loading branch information...
1 parent 954d3dd commit 65983e81f4ac5a6397da4c5705336cc3d8c7db98 Geoff Flarity committed Feb 10, 2012
Showing with 13 additions and 10 deletions.
  1. +2 −2 conf/nervous.json
  2. +5 −3 lib/graphite_axon.js
  3. +3 −2 lib/nervous.js
  4. +2 −2 lib/stdout_axon.js
  5. +1 −1 package.json
View
@@ -1,6 +1,6 @@
{
"system_type" : "graphite",
- "graphite_host" : "stats01-smc03",
+ "graphite_host" : "localhost",
"graphite_port" : "2003",
- "graphite_namespace" : "nervous.www02-smc03"
+ "graphite_namespace" : "nervous.localhost"
}
View
@@ -48,10 +48,11 @@ var GraphiteAxon = function ( namespace, host, port) {
//TODO eventually this could get big if we can't send them out for a while
+ //TODO message will be lost if the write fails...
while( this_axon.message_buffer.length > 0) {
var message = this_axon.message_buffer.shift();
- this_axon.write( message );
+ this_axon.tcp_connection.write( message );
}
};
@@ -62,6 +63,7 @@ var GraphiteAxon = function ( namespace, host, port) {
//TODO create an error message and enque it
//log error
log.error( 'graphite connection error: ' + error );
+
//destroy the connection so that reconnect fires
this_axon.tcp_connection.destroy();
@@ -74,10 +76,10 @@ var GraphiteAxon = function ( namespace, host, port) {
//log that we ended
log.info( 'disconnected from graphite, reconnecting in 10000 ms' );
- //reconnect after 1000 ms
+ //reconnect after 10000 ms
setTimeout( function () {
//need to reset the listeners?
- this_axon.tcp_connection.connect( this_axon.port, this_axon.port );
+ this_axon.tcp_connection.connect( this_axon.port, this_axon.host );
}, 10000 );
View
@@ -5,15 +5,16 @@ var steamlogger_helper = require('./streamlogger_helper');
//code
-//get a logger for for a log file relative to this path with the id 'main'
var load_plugins = function () {
var full_path_of_config = require.resolve( '../conf/nervous.json' );
debugger;
var root_path = path.resolve(full_path_of_config, '../..');
- var logger = steamlogger_helper.createStreamLogger( 'main', root_path + '/log/nervous.log');
+ //get a logger for for a log file relative to this path with the id 'main'
+ var logger = steamlogger_helper.createStreamLogger( 'main', root_path + '/log/nervous.log');
+
var config = JSON.parse(fs.readFileSync( full_path_of_config ) );
var system_type = config.system_type;
View
@@ -4,7 +4,7 @@ var util = require('util');
var events = require("events");
var streamlogger_helper = require('./streamlogger_helper');
-var log = streamlogger_helper.getStreamLogger( 'main' );
+//var log = streamlogger_helper.getStreamLogger( 'main' );
//code
var STDOUTAxon = function ( namespace) {
@@ -44,7 +44,7 @@ STDOUTAxon.prototype.fire = function( name, value, timestamp ) {
STDOUTAxon.prototype.misfire = function( err ) {
this_axon = this;
- log.error(err);
+ console.log( 'error: ' + err);
};
View
@@ -1,7 +1,7 @@
{
"name": "nervous",
"preferGlobal": false,
- "version": "0.1.1",
+ "version": "0.1.3",
"author": "Geoff Flarity <geoff.flarity@gmail.com>",
"description": "a simple plug-in based monitoring system",
"contributors": [

0 comments on commit 65983e8

Please sign in to comment.