mirror of
https://github.com/Unitech/pm2.git
synced 2026-02-01 16:57:09 +00:00
feature: add inspect feature, on runtime
This commit is contained in:
parent
9f2c4ca4c9
commit
39f242985b
7
bin/pm2
7
bin/pm2
@ -396,6 +396,13 @@ commander.command('id <name>')
|
||||
pm2.getProcessIdByName(name);
|
||||
});
|
||||
|
||||
// Inspect a process
|
||||
commander.command('inspect <name>')
|
||||
.description('inspect a process')
|
||||
.action(function(cmd) {
|
||||
pm2.inspect(cmd, commander);
|
||||
});
|
||||
|
||||
//
|
||||
// Stop and delete a process by name from database
|
||||
//
|
||||
|
||||
@ -15,6 +15,7 @@ var fs = require('fs');
|
||||
var fmt = require('../tools/fmt.js');
|
||||
var moment = require('moment');
|
||||
var pkg = require('../../package.json');
|
||||
const semver = require('semver');
|
||||
|
||||
module.exports = function(CLI) {
|
||||
|
||||
@ -38,7 +39,6 @@ module.exports = function(CLI) {
|
||||
*/
|
||||
CLI.prototype.report = function() {
|
||||
var that = this;
|
||||
var semver = require('semver');
|
||||
|
||||
function reporting(cb) {
|
||||
|
||||
@ -639,4 +639,22 @@ module.exports = function(CLI) {
|
||||
|
||||
launchMonitor();
|
||||
};
|
||||
|
||||
CLI.prototype.inspect = function(app_name, cb) {
|
||||
const that = this;
|
||||
if(semver.satisfies(process.versions.node, '>= 8.0.0')) {
|
||||
this.trigger(app_name, 'internal:inspect', function (err, res) {
|
||||
if(res[0].data.return === '') {
|
||||
Common.printOut(`Inspect disabled on ${app_name}`);
|
||||
} else {
|
||||
Common.printOut(`Inspect enabled on ${app_name} => go to chrome : chrome://inspect !!!`);
|
||||
}
|
||||
|
||||
that.exitCli(cst.SUCCESS_EXIT);
|
||||
});
|
||||
} else {
|
||||
Common.printOut('Inspect is available for node version >=8.x !');
|
||||
that.exitCli(cst.SUCCESS_EXIT);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,17 +1,33 @@
|
||||
/**
|
||||
/**
|
||||
* Copyright 2013 the PM2 project authors. All rights reserved.
|
||||
* Use of this source code is governed by a license that
|
||||
* can be found in the LICENSE file.
|
||||
*/
|
||||
// Inject custom modules
|
||||
if (process.env.pmx !== 'false') {
|
||||
require('pmx').init({
|
||||
const pmx = require('pmx');
|
||||
pmx.init({
|
||||
transactions: (process.env.km_link === 'true' && (process.env.trace === 'true' || process.env.deep_monitoring === 'true')) || false,
|
||||
http: process.env.km_link === 'true' || false,
|
||||
v8: process.env.v8 === 'true' || process.env.deep_monitoring === 'true' || false,
|
||||
event_loop_dump: process.env.event_loop_inspector === 'true' || process.env.deep_monitoring === 'true' || false,
|
||||
deep_metrics: process.env.deep_monitoring === 'true' || false
|
||||
});
|
||||
|
||||
if(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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(process.env.source_map_support) != "undefined" &&
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user