amqp-heartbeat
Advanced tools
Comparing version 1.2.0 to 1.3.0
60
index.js
@@ -10,3 +10,3 @@ var amqp = require( 'amqplib/callback_api' ) | ||
status : '', | ||
mqConn : null | ||
mqChannel : null | ||
} | ||
@@ -21,5 +21,5 @@ | ||
mqConnect( | ||
function ( err, conn ) { | ||
function ( err, ch ) { | ||
if ( ! err ) { | ||
heartbeat.mqConn = conn | ||
heartbeat.mqChannel = ch | ||
setInterval( amqpHeartbeat, timerInterval ) | ||
@@ -40,6 +40,17 @@ log.info( 'amqp-heartbeat', 'Started.' ) | ||
if ( err != null ) { | ||
log.error( 'amqp-heartbeat', err ); process.exit(1) | ||
log.error( 'amqp-heartbeat', err ) | ||
callback( err, null ) | ||
} else { | ||
conn.createChannel( | ||
function( err, ch ) { | ||
if ( err != null ) { | ||
log.error( 'amqp-heartbeat', err ) | ||
callback( err, null ) | ||
} else { | ||
//log.info( 'amqp-heartbeat', 'connected to '+heartbeat.rabbitMqURL ) | ||
callback( err, ch ) | ||
} | ||
} | ||
) | ||
} | ||
//log.info( 'amqp-heartbeat', 'connected to '+heartbeat.rabbitMqURL ) | ||
callback( err, conn ) | ||
} | ||
@@ -51,25 +62,16 @@ ) | ||
//log.info( 'amqp-heartbeat', 'start with '+heartbeat.rabbitMqURL ) | ||
heartbeat.mqConn.createChannel( | ||
function( err, ch ) { | ||
if ( err != null ) { | ||
log.error( 'amqp-heartbeat', err ); process.exit(1) | ||
} | ||
var host = 'unknown' | ||
if ( process.env['HOSTNAME'] ) host = process.env['HOSTNAME'] | ||
var heartbeatMsg = | ||
{ | ||
serviceName: heartbeat.serviceName, | ||
serviceID: heartbeat.serviceID, | ||
heartbeatTime: Date.now(), | ||
host: host, | ||
status: heartbeat.status | ||
} | ||
var msg = JSON.stringify( heartbeatMsg ) | ||
ch.assertExchange( 'heartbeats', 'topic', { durable : false } ); | ||
ch.publish( 'heartbeats', 'dashboard.collector', new Buffer( msg ) ) | ||
//log.info( 'amqp-heartbeat' + msg ); | ||
} | ||
) | ||
var host = 'unknown' | ||
if ( process.env['HOSTNAME'] ) host = process.env['HOSTNAME'] | ||
var heartbeatMsg = | ||
{ | ||
serviceName: heartbeat.serviceName, | ||
serviceID: heartbeat.serviceID, | ||
heartbeatTime: Date.now(), | ||
host: host, | ||
status: heartbeat.status | ||
} | ||
var msg = JSON.stringify( heartbeatMsg ) | ||
heartbeat.mqChannel.assertExchange( 'heartbeats', 'topic', { durable : false } ) | ||
heartbeat.mqChannel.publish( 'heartbeats', 'dashboard.collector', new Buffer( msg ) ) | ||
//log.info( 'amqp-heartbeat' + msg ); | ||
} |
{ | ||
"name":"amqp-heartbeat", | ||
"version":"1.2.0", | ||
"version":"1.3.0", | ||
"description":"Send heartbeat messages to RabbitMQ", | ||
@@ -5,0 +5,0 @@ "author":"ma-ha", |
var heartbeat = require ( '../' ) // stand alone: replace with require( 'amqp-heartbeat' ) | ||
heartbeat.setStatus( 'ohhh -- started' ) | ||
heartbeat.setStatus( 'some message' ) | ||
heartbeat.start( 'amqp://user:password@localhost', 'Some Service Name' ) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5264
70