2016-03-22 23:33:43 +01:00
|
|
|
/**
|
2026-02-08 15:04:58 +01:00
|
|
|
* Copyright 2013-present the PM2 project authors. All rights reserved.
|
2016-03-22 23:33:43 +01:00
|
|
|
* Use of this source code is governed by a license that
|
|
|
|
|
* can be found in the LICENSE file.
|
|
|
|
|
*/
|
2014-09-21 00:39:12 +02:00
|
|
|
|
2014-10-01 16:32:54 +02:00
|
|
|
var Utility = require('./Utility.js');
|
|
|
|
|
|
2016-01-02 11:06:50 +01:00
|
|
|
module.exports = function(God) {
|
2014-10-01 16:32:54 +02:00
|
|
|
|
2014-09-21 00:39:12 +02:00
|
|
|
God.notify = function(action_name, data, manually) {
|
|
|
|
|
God.bus.emit('process:event', {
|
|
|
|
|
event : action_name,
|
|
|
|
|
manually : typeof(manually) == 'undefined' ? false : true,
|
2016-03-21 19:09:25 +01:00
|
|
|
process : Utility.formatCLU(data),
|
2014-10-01 16:32:54 +02:00
|
|
|
at : Utility.getDate()
|
2014-09-21 00:39:12 +02:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
God.notifyByProcessId = function(opts, cb) {
|
|
|
|
|
if (typeof(opts.id) === 'undefined') { return cb(new Error('process id missing')); }
|
|
|
|
|
var proc = God.clusters_db[opts.id];
|
|
|
|
|
if (!proc) { return cb(new Error('process id doesnt exists')); }
|
|
|
|
|
|
|
|
|
|
God.bus.emit('process:event', {
|
|
|
|
|
event : opts.action_name,
|
|
|
|
|
manually : typeof(opts.manually) == 'undefined' ? false : true,
|
2016-03-21 19:09:25 +01:00
|
|
|
process : Utility.formatCLU(proc),
|
2014-10-01 16:32:54 +02:00
|
|
|
at : Utility.getDate()
|
2014-09-21 00:39:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
process.nextTick(function() {
|
|
|
|
|
return cb ? cb(null) : false;
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
};
|