Unitech/pm2-interface — pull request #6 by jmingov (2013-12-09 04:02:46+00:00)
Title: axon/axon-rpc events

This solves https://github.com/Unitech/pm2-interface/issues/4

the *disconnect* event never gets fired:

sub_sock.on('disconnect', function() {
//never
log('Error4');
self.emit('close'); //never .
});

we need to listen the **close** event:

sub_sock.on('close', function() { ... });

to test:

var ipm2 = require('pm2-interface')(); // ready events
ipm2.on('rpc_sock:ready', function() {
console.log('rpc_sock:ready');
});
ipm2.on('rpc_sock:closed', function() {
console.log('rpc_sock:closed');
});

ipm2.on('rpc_sock:reconnecting', function() {
console.log('rpc_sock:reconnecting');
});
ipm2.on('sub_sock:ready', function() {
console.log('sub_sock:ready');
});
ipm2.on('sub_sock:closed', function() {
console.log('sub_sock:closed');
});

ipm2.on('sub_sock:reconnecting', function() {
console.log('sub_sock:reconnecting');
});

ipm2.disconnect(); // close events

testing reconect events:

do `pm2 kill` and restart the process.