Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.55k stars 2.63k forks source link

support-colors module does not work with pm2 #4155

Closed jirikrepl closed 4 years ago

jirikrepl commented 5 years ago

What's going wrong?

I use debug with support-colors which supports 16M colors. It works well if I run my app without pm2 just npm run dev. But if I run my app with pm2 and do pm2 logs or pm2 logs --raw I can still see just a few colors. I already reported my problem here https://github.com/visionmedia/debug/issues/682#issuecomment-461777506

How could we reproduce this issue?

If I evaluate this code:

const supportsColor = require('supports-color');

console.log(supportsColor);

if (supportsColor.stdout) {
    console.log('Terminal stdout supports color');
}

if (supportsColor.stdout.has256) {
    console.log('Terminal stdout supports 256 colors');
}

if (supportsColor.stderr.has16m) {
    console.log('Terminal stderr supports 16 million colors (truecolor)');
}

this is the output when when using pm2 log

2019-02-08 12:48:54: --------
2019-02-08 12:48:54: { supportsColor: [Function: getSupportLevel],
  stdout: false,
  stderr: false }
--------

this is the output when I use npm run dev

--------
{ supportsColor: [Function: getSupportLevel],
  stdout: { level: 3, hasBasic: true, has256: true, has16m: true },
  stderr: { level: 3, hasBasic: true, has256: true, has16m: true } }
--------
Terminal stdout supports color
Terminal stdout supports 256 colors
Terminal stderr supports 16 million colors (truecolor)

Supporting information

$ pm2 report

MacBook:microservices-pybytes jirkakrepl$ pm2 report
===============================================================================
--- PM2 REPORT (Fri Feb 08 2019 13:07:48 GMT+0100 (CET)) ----------------------
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.0.0
node version         : 8.9.1
node path            : /Users/jirkakrepl/.nvm/versions/node/v8.9.1/bin/pm2
argv                 : /Users/jirkakrepl/.nvm/versions/node/v8.9.1/bin/node,/Users/jirkakrepl/.nvm/versions/node/v8.9.1/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : jirkakrepl
uid                  : 501
gid                  : 20
uptime               : 32min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.0.0
node version         : 8.9.1
node path            : /Users/jirkakrepl/.nvm/versions/node/v8.9.1/bin/pm2
argv                 : /Users/jirkakrepl/.nvm/versions/node/v8.9.1/bin/node,/Users/jirkakrepl/.nvm/versions/node/v8.9.1/bin/pm2,report
argv0                : node
user                 : jirkakrepl
uid                  : 501
gid                  : 20
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : darwin
type                 : Darwin
cpus                 : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
cpus nb              : 8
freemem              : 4013498368
totalmem             : 17179869184
home                 : /Users/jirkakrepl
===============================================================================
--- PM2 list -----------------------------------------------
┌───────────┬────┬──────┬──────┬────────┬─────────┬────────┬──────┬───────────┬────────────┬──────────┐
│ App name  │ id │ mode │ pid  │ status │ restart │ uptime │ cpu  │ mem       │ user       │ watching │
├───────────┼────┼──────┼──────┼────────┼─────────┼────────┼──────┼───────────┼────────────┼──────────┤
│ api       │ 4  │ fork │ 1003 │ online │ 0       │ 31m    │ 0%   │ 36.9 MB   │ jirkakrepl │ enabled  │
│ mqtt      │ 0  │ fork │ 6231 │ online │ 11      │ 12m    │ 0.1% │ 36.1 MB   │ jirkakrepl │ enabled  │
│ pyauth    │ 1  │ fork │ 782  │ online │ 0       │ 32m    │ 0%   │ 36.2 MB   │ jirkakrepl │ enabled  │
│ pybill    │ 2  │ fork │ 965  │ online │ 0       │ 32m    │ 0%   │ 36.4 MB   │ jirkakrepl │ enabled  │
│ react     │ 5  │ fork │ 1008 │ online │ 0       │ 31m    │ 0%   │ 37.4 MB   │ jirkakrepl │ disabled │
│ sigfox    │ 6  │ fork │ 1012 │ online │ 0       │ 31m    │ 0%   │ 37.3 MB   │ jirkakrepl │ enabled  │
│ ttnbridge │ 3  │ fork │ 966  │ online │ 0       │ 32m    │ 0%   │ 37.2 MB   │ jirkakrepl │ enabled  │
└───────────┴────┴──────┴──────┴────────┴─────────┴────────┴──────┴───────────┴────────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/Users/jirkakrepl/.pm2/pm2.log last 20 lines:
PM2        | [2019-02-08T12:48:02.010Z] PM2 log: Starting execution sequence in -fork mode- for app name:mqtt id:0
PM2        | [2019-02-08T12:48:05.016Z] PM2 log: App name:mqtt id:0 online
PM2        | [2019-02-08T12:48:25.426Z] PM2 error: Change detected on path src/start.js for app mqtt - restarting
PM2        | [2019-02-08T12:48:25.426Z] PM2 log: Stopping app:mqtt id:0
PM2        | [2019-02-08T12:48:25.487Z] PM2 log: App [mqtt] with id [0] and pid [4373], exited with code [0] via signal [SIGINT]
PM2        | [2019-02-08T12:48:25.579Z] PM2 log: pid=4373 msg=process killed
PM2        | [2019-02-08T12:48:25.582Z] PM2 log: Starting execution sequence in -fork mode- for app name:mqtt id:0
PM2        | [2019-02-08T12:48:28.587Z] PM2 log: App name:mqtt id:0 online
PM2        | [2019-02-08T12:48:52.317Z] PM2 error: Change detected on path src/start.js for app mqtt - restarting
PM2        | [2019-02-08T12:48:52.317Z] PM2 log: Stopping app:mqtt id:0
PM2        | [2019-02-08T12:48:52.381Z] PM2 log: App [mqtt] with id [0] and pid [4511], exited with code [0] via signal [SIGINT]
PM2        | [2019-02-08T12:48:52.475Z] PM2 log: pid=4511 msg=process killed
PM2        | [2019-02-08T12:48:52.475Z] PM2 log: Starting execution sequence in -fork mode- for app name:mqtt id:0
PM2        | [2019-02-08T12:48:55.480Z] PM2 log: App name:mqtt id:0 online
PM2        | [2019-02-08T12:55:24.279Z] PM2 error: Change detected on path src/start.js for app mqtt - restarting
PM2        | [2019-02-08T12:55:24.279Z] PM2 log: Stopping app:mqtt id:0
PM2        | [2019-02-08T12:55:24.337Z] PM2 log: App [mqtt] with id [0] and pid [4647], exited with code [0] via signal [SIGINT]
PM2        | [2019-02-08T12:55:24.432Z] PM2 log: pid=4647 msg=process killed
PM2        | [2019-02-08T12:55:24.433Z] PM2 log: Starting execution sequence in -fork mode- for app name:mqtt id:0
PM2        | [2019-02-08T12:55:27.440Z] PM2 log: App name:mqtt id:0 online

Please copy/paste the above report in your issue on https://github.com/Unitech/pm2/issues
MacBook:microservices-pybytes jirkakrepl$
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.