Skip to content

Commit 1960bae

Browse files
committed
quickfix dbl check pm2 report + skip test graceful reload for 0.12
1 parent 9af0545 commit 1960bae

File tree

2 files changed

+70
-53
lines changed

2 files changed

+70
-53
lines changed

lib/API/Extra.js

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,69 +36,82 @@ module.exports = function(CLI) {
3636
* @method getVersion
3737
* @callback cb
3838
*/
39-
CLI.prototype.report = function(cb) {
39+
CLI.prototype.report = function() {
4040
var that = this;
41+
var semver = require('semver');
4142

42-
var Log = require('./Log');
43-
44-
that.Client.executeRemote('getReport', {}, function(err, report) {
45-
fmt.sep();
46-
fmt.title('PM2 REPORT (' + new Date() + ')');
47-
fmt.sep();
48-
fmt.title(chalk.bold.blue('Daemon'));
49-
fmt.field('pm2d version', report.pm2_version);
50-
fmt.field('node version', report.node_version);
51-
fmt.field('node path', report.node_path);
52-
fmt.field('argv', report.argv);
53-
fmt.field('argv0', report.argv0);
54-
fmt.field('user', report.user);
55-
fmt.field('uid', report.uid);
56-
fmt.field('gid', report.gid);
57-
fmt.field('uptime', moment(new Date()).diff(report.started_at, 'minute') + 'min');
58-
59-
fmt.sep();
60-
fmt.title(chalk.bold.blue('CLI'));
61-
fmt.field('local pm2', pkg.version);
62-
fmt.field('node version', process.versions.node);
63-
fmt.field('node path', process.env['_']);
64-
fmt.field('argv', process.argv);
65-
fmt.field('argv0', process.argv0);
66-
fmt.field('user', process.env.USER);
67-
fmt.field('uid', process.geteuid());
68-
fmt.field('gid', process.getegid());
69-
70-
var os = require('os');
71-
72-
fmt.sep();
73-
fmt.title(chalk.bold.blue('System info'));
74-
fmt.field('arch', os.arch());
75-
fmt.field('platform', os.platform());
76-
fmt.field('type', os.type());
77-
fmt.field('cpus', os.cpus()[0].model);
78-
fmt.field('cpus nb', Object.keys(os.cpus()).length);
79-
fmt.field('freemem', os.freemem());
80-
fmt.field('totalmem', os.totalmem());
81-
fmt.field('home', os.homedir());
43+
function reporting(cb) {
8244

83-
that.Client.executeRemote('getMonitorData', {}, function(err, list) {
45+
var Log = require('./Log');
8446

47+
that.Client.executeRemote('getReport', {}, function(err, report) {
48+
fmt.sep();
49+
fmt.title('PM2 REPORT (' + new Date() + ')');
8550
fmt.sep();
86-
fmt.title(chalk.bold.blue('PM2 list'));
87-
that.list();
51+
fmt.title(chalk.bold.blue('Daemon'));
52+
fmt.field('pm2d version', report.pm2_version);
53+
fmt.field('node version', report.node_version);
54+
fmt.field('node path', report.node_path);
55+
fmt.field('argv', report.argv);
56+
fmt.field('argv0', report.argv0);
57+
fmt.field('user', report.user);
58+
fmt.field('uid', report.uid);
59+
fmt.field('gid', report.gid);
60+
fmt.field('uptime', moment(new Date()).diff(report.started_at, 'minute') + 'min');
8861

89-
UX.dispAsTable(list, that.gl_interact_infos);
62+
fmt.sep();
63+
fmt.title(chalk.bold.blue('CLI'));
64+
fmt.field('local pm2', pkg.version);
65+
fmt.field('node version', process.versions.node);
66+
fmt.field('node path', process.env['_']);
67+
fmt.field('argv', process.argv);
68+
fmt.field('argv0', process.argv0);
69+
fmt.field('user', process.env.USER);
70+
fmt.field('uid', process.geteuid());
71+
fmt.field('gid', process.getegid());
72+
73+
var os = require('os');
9074

9175
fmt.sep();
92-
fmt.title(chalk.bold.blue('Daemon logs'));
93-
Log.tail([{
94-
path : cst.PM2_LOG_FILE_PATH,
95-
app_name : 'PM2',
96-
type : 'PM2'
97-
}], 20, false, function() {
98-
console.log(chalk.bold.green('Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues'));
99-
that.exitCli(cst.SUCCESS_EXIT);
76+
fmt.title(chalk.bold.blue('System info'));
77+
fmt.field('arch', os.arch());
78+
fmt.field('platform', os.platform());
79+
fmt.field('type', os.type());
80+
fmt.field('cpus', os.cpus()[0].model);
81+
fmt.field('cpus nb', Object.keys(os.cpus()).length);
82+
fmt.field('freemem', os.freemem());
83+
fmt.field('totalmem', os.totalmem());
84+
fmt.field('home', os.homedir());
85+
86+
that.Client.executeRemote('getMonitorData', {}, function(err, list) {
87+
88+
fmt.sep();
89+
fmt.title(chalk.bold.blue('PM2 list'));
90+
that.list();
91+
92+
UX.dispAsTable(list, that.gl_interact_infos);
93+
94+
fmt.sep();
95+
fmt.title(chalk.bold.blue('Daemon logs'));
96+
Log.tail([{
97+
path : cst.PM2_LOG_FILE_PATH,
98+
app_name : 'PM2',
99+
type : 'PM2'
100+
}], 20, false, function() {
101+
console.log(chalk.bold.green('Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues'));
102+
that.exitCli(cst.SUCCESS_EXIT);
103+
});
100104
});
101105
});
106+
}
107+
108+
that.Client.executeRemote('getVersion', {}, function(err, data) {
109+
if (semver.satisfies(data, '>= 2.6.0'))
110+
reporting();
111+
else {
112+
Common.printError(cst.PREFIX_MSG_ERR + 'You need to update your Daemon, please type `$ pm2 update`');
113+
that.exitCli(cst.ERROR_EXIT);
114+
}
102115
});
103116
};
104117

test/programmatic/graceful.mocha.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ var PM2 = require('../..');
55
var should = require('should');
66
var path = require('path');
77
var Plan = require('../helpers/plan.js');
8+
var semver = require('semver');
89

910
process.chdir(__dirname);
1011

1112
describe('Wait ready / Graceful start / restart', function() {
1213
this.timeout(5000);
1314

15+
if (!semver.satisfies(process.version, '>= 4.0.0'))
16+
process.exit(0);
17+
1418
var pm2 = new PM2.custom({
1519
cwd : '../fixtures/listen-timeout/',
1620
independent : true

0 commit comments

Comments
 (0)