mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
module.exports = {
|
|
injectModules: function() {
|
|
if (process.env.pmx !== 'false') {
|
|
const pmx = require('@pm2/io');
|
|
|
|
let conf = {};
|
|
|
|
if (process.env.io) {
|
|
const io = JSON.parse(process.env.io);
|
|
conf = io.conf ? io.conf : conf;
|
|
}
|
|
|
|
var activate = process.env.km_link == 'true' || process.env.deep_monitoring === 'true' || false;
|
|
|
|
let defaultConf = {
|
|
metrics: {
|
|
network: activate,
|
|
transaction: {
|
|
tracing: activate
|
|
},
|
|
deepMetrics: activate,
|
|
v8: activate
|
|
},
|
|
actions: {
|
|
eventLoopDump: activate,
|
|
profilingCpu: activate,
|
|
profilingHeap: activate
|
|
}
|
|
};
|
|
|
|
const mergedConf = Object.assign(defaultConf, conf);
|
|
|
|
pmx.init(mergedConf);
|
|
|
|
if (activate && require('semver').satisfies(process.versions.node, '>= 8.0.0')) {
|
|
var url = '';
|
|
pmx.action('internal:inspect', function(reply) {
|
|
const inspector = require('inspector');
|
|
if(url === '') {
|
|
inspector.open();
|
|
url = inspector.url();
|
|
} else {
|
|
inspector.close();
|
|
url = '';
|
|
}
|
|
reply(url);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|