Skip to content

Commit dc8fe09

Browse files
committed
#3278 #3345: --silent -s and -v will not print banner anymore
1 parent 0c039cb commit dc8fe09

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

bin/pm2

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ var PM2 = require('../lib/API.js');
1515
var pkg = require('../package.json');
1616
var tabtab = require('../lib/completion.js');
1717

18+
// Early detection of silent to avoid printing motd
19+
if (process.argv.indexOf('--silent') > -1 ||
20+
process.argv.indexOf('-s') > -1 ||
21+
process.argv.indexOf('-v') > -1) {
22+
process.env.PM2_DISCRETE_MODE = true;
23+
}
24+
1825
var pm2 = new PM2();
1926

2027
commander.version(pkg.version)
@@ -112,12 +119,6 @@ if (process.argv.indexOf('-s') > -1) {
112119
}
113120
}
114121

115-
// Override -v behavior (do not spawn daemon)
116-
if (process.argv.indexOf('-v') > -1) {
117-
console.log(pkg.version);
118-
return process.exit(0);
119-
}
120-
121122
function beginCommandProcessing() {
122123
pm2.getVersion(function(err, remote_version) {
123124
if (!err && (pkg.version != remote_version)) {

lib/Client.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ Client.prototype.start = function(cb) {
104104
Common.printError(err);
105105
return cb ? cb(err) : process.exit(that.conf.ERROR_EXIT);
106106
}
107-
Common.printOut(that.conf.PREFIX_MSG + 'PM2 Successfully daemonized');
107+
108+
if (!process.env.PM2_DISCRETE_MODE)
109+
Common.printOut(that.conf.PREFIX_MSG + 'PM2 Successfully daemonized');
110+
108111
that.launchRPC(function(err, meta) {
109112
return cb(null, {
110113
daemon_mode : that.conf.daemon_mode,
@@ -155,6 +158,14 @@ Client.prototype.initFileStructure = function (opts) {
155158
}
156159
}
157160

161+
if (process.env.PM2_DISCRETE_MODE) {
162+
try {
163+
fs.writeFileSync(path.join(opts.PM2_HOME, 'touch'), Date.now());
164+
} catch(e) {
165+
debug(e.stack || e);
166+
}
167+
}
168+
158169
if (!process.env.PM2_PROGRAMMATIC && !fs.existsSync(path.join(opts.PM2_HOME, 'touch'))) {
159170
var dt = fs.readFileSync(path.join(__dirname, opts.KEYMETRICS_BANNER));
160171
console.log(dt.toString());
@@ -224,7 +235,8 @@ Client.prototype.launchDaemon = function(opts, cb) {
224235
node_args = node_args.concat(process.env.PM2_NODE_OPTIONS.split(' '));
225236
node_args.push(ClientJS);
226237

227-
Common.printOut(that.conf.PREFIX_MSG + 'Spawning PM2 daemon with pm2_home=' + this.pm2_home);
238+
if (!process.env.PM2_DISCRETE_MODE)
239+
Common.printOut(that.conf.PREFIX_MSG + 'Spawning PM2 daemon with pm2_home=' + this.pm2_home);
228240

229241
var interpreter = 'node';
230242

lib/binaries/DevCLI.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
'use strict';
33

44
process.env.PM2_NO_INTERACTION = 'true';
5+
// Do not print banner
6+
process.env.PM2_DISCRETE_MODE = true;
57

68
var commander = require('commander');
79

lib/binaries/Runtime.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var path = require('path');
1212

1313
var pm2;
1414

15+
// Do not print banner
16+
process.env.PM2_DISCRETE_MODE = true;
17+
1518
commander.version(pkg.version)
1619
.description('pm2-runtime is an automatic pmx injection that runs in simulated no-daemon environment')
1720
.option('--auto-manage', 'keep application online after command exit')

lib/binaries/Runtime4Docker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ var pkg = require('../../package.json');
1212
var path = require('path');
1313
var pm2;
1414

15+
// Do not print banner
16+
process.env.PM2_DISCRETE_MODE = true;
17+
1518
commander.version(pkg.version)
1619
.description('pm2-docker is a drop-in replacement node.js binary with some interesting production features')
1720
.option('-i --instances <number>', 'launch [number] of processes automatically load-balanced. Increase overall performances and performance stability.')

0 commit comments

Comments
 (0)