mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
41 lines
642 B
JavaScript
41 lines
642 B
JavaScript
|
|
var pm2 = require('..');
|
|
|
|
pm2.connect(function() {
|
|
|
|
pm2.start('echo.js', function() {
|
|
|
|
setInterval(function() {
|
|
pm2.restart('echo', function() {
|
|
});
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
pm2.launchBus(function(err, bus) {
|
|
console.log('connected', bus);
|
|
|
|
bus.on('log:out', function(data) {
|
|
if (data.process.name == 'echo')
|
|
console.log(arguments);
|
|
});
|
|
|
|
bus.on('reconnect attempt', function() {
|
|
console.log('Bus reconnecting');
|
|
});
|
|
|
|
bus.on('close', function() {
|
|
console.log('Bus closed');
|
|
});
|
|
|
|
});
|
|
|
|
/**
|
|
* Exiting
|
|
*/
|
|
//pm2.disconnectBus(); // For Bus system
|
|
//pm2.disconnect(); // For RPC connection
|