mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
refactor
This commit is contained in:
parent
1b782e4a87
commit
4f882acb33
@ -14,6 +14,7 @@ var extItps = require('./interpreter.json');
|
||||
var p = path;
|
||||
|
||||
var Stringify = require('json-stringify-safe');
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
var InteractorDaemonizer = require('./Interactor/InteractorDaemonizer.js');
|
||||
/**
|
||||
@ -190,8 +191,6 @@ Common.validateApp = function(appConf, outputter) {
|
||||
* @return CallExpression
|
||||
*/
|
||||
Common.exitCli = function(code) {
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
InteractorDaemonizer.disconnectRPC(function() {
|
||||
Satan.disconnectRPC(function() {
|
||||
process.exit(code || 0);
|
||||
@ -224,7 +223,6 @@ Common.printOut = function() {
|
||||
|
||||
Common.getAllProcess = function(cb) {
|
||||
var found_proc = [];
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
Satan.executeRemote('getMonitorData', {}, function(err, list) {
|
||||
if (err) {
|
||||
@ -243,7 +241,6 @@ Common.getAllProcess = function(cb) {
|
||||
|
||||
Common.getAllProcessId = function(cb) {
|
||||
var found_proc = [];
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
Satan.executeRemote('getMonitorData', {}, function(err, list) {
|
||||
if (err) {
|
||||
@ -261,7 +258,6 @@ Common.getAllProcessId = function(cb) {
|
||||
|
||||
Common.getProcessIdByName = function(name, cb) {
|
||||
var found_proc = [];
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
Satan.executeRemote('getMonitorData', {}, function(err, list) {
|
||||
if (err) {
|
||||
@ -282,7 +278,6 @@ Common.getProcessIdByName = function(name, cb) {
|
||||
|
||||
Common.getProcessByName = function(name, cb) {
|
||||
var found_proc = [];
|
||||
var Satan = require('./Satan.js');
|
||||
|
||||
Satan.executeRemote('getMonitorData', {}, function(err, list) {
|
||||
if (err) {
|
||||
|
||||
23
lib/Satan.js
23
lib/Satan.js
@ -6,15 +6,14 @@
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
|
||||
var rpc = require('pm2-axon-rpc');
|
||||
var axon = require('pm2-axon');
|
||||
var debug = require('debug')('pm2:satan');
|
||||
var util = require('util');
|
||||
var fs = require('fs');
|
||||
var p = require('path');
|
||||
var cst = require('../constants.js');
|
||||
var Common = require('./Common.js');
|
||||
var rpc = require('pm2-axon-rpc');
|
||||
var axon = require('pm2-axon');
|
||||
var debug = require('debug')('pm2:satan');
|
||||
var util = require('util');
|
||||
var fs = require('fs');
|
||||
var p = require('path');
|
||||
var cst = require('../constants.js');
|
||||
var Utility = require('./Utility.js');
|
||||
|
||||
/**
|
||||
* Export
|
||||
@ -243,7 +242,7 @@ Satan.remoteWrapper = function() {
|
||||
God.clusters_db[msg.process.pm_id].pm2_env.name = msg.data.name;
|
||||
|
||||
Object.keys(msg.data).forEach(function(conf_key) {
|
||||
God.clusters_db[msg.process.pm_id].pm2_env.axm_options[conf_key] = Common.serialize(msg.data[conf_key]);
|
||||
God.clusters_db[msg.process.pm_id].pm2_env.axm_options[conf_key] = Utility.serialize(msg.data[conf_key]);
|
||||
});
|
||||
} catch(e) {
|
||||
console.error(e.stack || e);
|
||||
@ -261,7 +260,7 @@ Satan.remoteWrapper = function() {
|
||||
if (!msg.process || !God.clusters_db[msg.process.pm_id])
|
||||
return console.error('Unknown id %s', msg.process.pm_id);
|
||||
|
||||
God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor = Common.serialize(msg.data);
|
||||
God.clusters_db[msg.process.pm_id].pm2_env.axm_monitor = Utility.serialize(msg.data);
|
||||
delete msg;
|
||||
});
|
||||
|
||||
@ -276,7 +275,7 @@ Satan.remoteWrapper = function() {
|
||||
delete data_v;
|
||||
return false;
|
||||
}
|
||||
return pub.emit(this.event, Common.serialize(data_v));
|
||||
return pub.emit(this.event, Utility.serialize(data_v));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
|
||||
var Stringify = require('json-stringify-safe');
|
||||
|
||||
var Utility = module.exports = {
|
||||
getDate : function() {
|
||||
return Math.round(Date.now() / 1000);
|
||||
},
|
||||
serialize : function(data) {
|
||||
return JSON.parse(Stringify(data));
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user