diff --git a/lib/mon.js b/lib/mon.js index a0502c5..6886636 100644 --- a/lib/mon.js +++ b/lib/mon.js @@ -358,6 +358,7 @@ Monitor.prototype._startWatching = function(){ this._throttleRefresh(); }.bind(this)); + // Enforce a refresh operation if RPC is not online. this._throttleRefresh(); }; diff --git a/lib/pm.js b/lib/pm.js index 79b9f48..517b017 100644 --- a/lib/pm.js +++ b/lib/pm.js @@ -26,9 +26,18 @@ pm.sub = function(sockPath, cb){ var sub = axon.socket('sub-emitter'), sub_sock = sub.connect(sockPath); - sub.on('process:*', function(event, data){ - if (data && !!~allowedEvents.indexOf(data.event)) { - cb(data); + // Once awake from sleeping. + sub.on('log:*', function(e, d){ + // Do not subscribe it. + sub.off('log:*'); + d.event = 'awake'; + cb(d); + }); + + // Process events. + sub.on('process:*', function(e, d){ + if (d && !!~allowedEvents.indexOf(d.event)) { + cb(d); } }); };