1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Utility = require('./Utility.js');
|
8 |
|
9 | module.exports = function(God) {
|
10 |
|
11 | God.notify = function(action_name, data, manually) {
|
12 | God.bus.emit('process:event', {
|
13 | event : action_name,
|
14 | manually : typeof(manually) == 'undefined' ? false : true,
|
15 | process : Utility.formatCLU(data),
|
16 | at : Utility.getDate()
|
17 | });
|
18 | };
|
19 |
|
20 | God.notifyByProcessId = function(opts, cb) {
|
21 | if (typeof(opts.id) === 'undefined') { return cb(new Error('process id missing')); }
|
22 | var proc = God.clusters_db[opts.id];
|
23 | if (!proc) { return cb(new Error('process id doesnt exists')); }
|
24 |
|
25 | God.bus.emit('process:event', {
|
26 | event : opts.action_name,
|
27 | manually : typeof(opts.manually) == 'undefined' ? false : true,
|
28 | process : Utility.formatCLU(proc),
|
29 | at : Utility.getDate()
|
30 | });
|
31 |
|
32 | process.nextTick(function() {
|
33 | return cb ? cb(null) : false;
|
34 | });
|
35 | return false;
|
36 | };
|
37 | };
|