Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pm2.describe('gxb-box-pm2', function (err, processDescription) {
if (err) {
reject(err);
} else {
// 启动消息BUS,监听日志
if ((!is_started) && (processDescription && processDescription.length > 0)) {
let websocket = io.connect(url);
setInterval(function () {
pm2.describe('gxb-box-pm2', function (processDescription) {
websocket.emit('system', processDescription);
});
}, 1000);
pm2.launchBus(function (err, bus) {
if (err) return reject(err);
is_started = true;
bus.on('log:out', function (packet) {
websocket.emit('message', 'out', packet.data);
});
bus.on('log:err', function (packet) {
websocket.emit('message', 'err', packet.data);
});
return resolve(processDescription);
});
} else {
resolve(processDescription);
}
}
});
});
restart_time,
// MONIT OBJECT INJECT
...monit
}
}
});
}));
}
}));
}
}));
}), 10000); // 10 seconds.
// Bus system - event monitoring
pm2.launchBus(Meteor.bindEnvironment((err, bus) => {
if (_.isNull(err)) {
bus.on('*', Meteor.bindEnvironment((type, query) => {
// EVENTS STOP, START, ...
if (_.isEqual(type, 'process:event')) {
let { PORT, name } = query.process;
const application = Applications.findOne({ bundleId: name });
if (application) {
// CHANGE STATUS
return Applications.update({ bundleId: name }, {
$set: {
status: STATUS_MAPPER[query.event.toUpperCase()],
'env.PORT': PORT
_launchBus(events) {
const _this = this;
pm2.launchBus(function (err, bus) {
bus.on('process:event', packet => {
if (events.indexOf(packet.event) != -1) {
console.log(packet)
let fields = [
{
"title": "Event",
"value": packet.event,
"short": false
},
{
"title": "Server",
"value": _this._config.info.serverName || 'UNKNOWN SERVER',
"short": false
.then(() => Promise.fromNode(callback => pm2.launchBus(callback)))
.then(bus => {