Unitech / pm2-interface

Deprecated
Other
90 stars 14 forks source link

axon/axon-rpc events #6

Closed jmingov closed 10 years ago

jmingov commented 10 years ago

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.