Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed Aug 17, 2020
1 parent 476331f commit 14871cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

## 4.5.0

- feature: On pm2 start or restart, display logs in terminal for 10 seconds #4765

## 4.4.1

- feature drop: autodump fixes #4763
Expand Down
18 changes: 10 additions & 8 deletions lib/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -1711,15 +1711,16 @@ class API {
var systemdata = null
var acted = []

if ((code != 0 && code != null)) {
return that.exitCli(code ? code : conf.SUCCESS_EXIT);
}

if (apps_acted && apps_acted.length > 0) {
apps_acted.forEach(proc => {
acted.push(proc.pm2_env ? proc.pm2_env.pm_id : proc.pm_id)
})
}

if ((code != 0 && code != null)) {
return that.exitCli(code ? code : conf.SUCCESS_EXIT);
}
// Do nothing if PM2 called programmatically and not called from CLI (also in exitCli)
if ((conf.PM2_PROGRAMMATIC && process.env.PM2_USAGE != 'CLI'))
return false;
Expand Down Expand Up @@ -1767,13 +1768,14 @@ class API {
global._auto_exit = true;
return that.streamLogs('all', 0, false, 'HH:mm:ss', false);
}
else if (!process.env.TRAVIS && process.env.NODE_ENV != 'test' && acted.length > 0 && (process.stdout.isTTY || commander.attach === true)) {
// if (process.stdout.isTTY) if looking for start logs
else if (!process.env.TRAVIS && process.env.NODE_ENV != 'test' && acted.length > 0 && (commander.attach === true)) {
Common.info(`Log streaming apps id: ${chalk.cyan(acted.join(' '))}, exit with Ctrl-C or will exit in 10secs`)

setTimeout(() => {
Common.info(`Log streaming exited automatically, run 'pm2 logs' to continue watching logs`)
return that.exitCli(code ? code : conf.SUCCESS_EXIT);
}, 10000)
// setTimeout(() => {
// Common.info(`Log streaming exited automatically, run 'pm2 logs' to continue watching logs`)
// return that.exitCli(code ? code : conf.SUCCESS_EXIT);
// }, 10000)

return acted.forEach((proc_name) => {
that.streamLogs(proc_name, 0, false, null, false);
Expand Down

0 comments on commit 14871cd

Please sign in to comment.