Unitech / Unitech/pm2

Log configuration is ignored in cluster mode (as in #3384)

Open
#4,816 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
43.3k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

What's going wrong?

Hello,
Please find my problem here. Thanks for your time.

Log configuration is not correct in cluster mode (in docker)
In cluster mode, logs are going to PM2 logs files in /root/.pm2/logs/API-out-X.log, and to standard output.
In docker mode, logs must go to standard output.

find /root/.pm2/ -ls
 10460670      4 drwxr-xr-x   5 root     root         4096 Aug 15 08:54 /root/.pm2/
   132989      4 -rw-r--r--   1 root     root            2 Aug 15 08:54 /root/.pm2/module_conf.json
   133162      0 srwxrwxr-x   1 root     root            0 Aug 15 08:54 /root/.pm2/pub.sock
 10460671      4 drwxr-xr-x   2 root     root         4096 Aug 15 08:54 /root/.pm2/logs
   133165 601272 -rw-r--r--   1 root     root     615697549 Aug 17 09:20 /root/.pm2/logs/API-out-0.log
   133168 600580 -rw-r--r--   1 root     root     614989062 Aug 17 09:20 /root/.pm2/logs/API-out-1.log
   133171 600288 -rw-r--r--   1 root     root     614687810 Aug 17 09:20 /root/.pm2/logs/API-out-2.log
   133172      4 -rw-r--r--   1 root     root           178 Aug 15 08:54 /root/.pm2/logs/API-error-2.log
   133169      4 -rw-r--r--   1 root     root           178 Aug 15 08:54 /root/.pm2/logs/API-error-1.log
   133166      4 -rw-r--r--   1 root     root           178 Aug 15 08:54 /root/.pm2/logs/API-error-0.log

   133161      4 -rw-r--r--   1 root     root             1 Aug 15 08:54 /root/.pm2/pm2.pid
 15878703      4 drwxr-xr-x   2 root     root          4096 Aug 15 08:54 /root/.pm2/pids
   133164      4 -rw-r--r--   1 root     root             2 Aug 15 08:54 /root/.pm2/pids/API-0.pid
   133170      4 -rw-r--r--   1 root     root             2 Aug 15 08:54 /root/.pm2/pids/API-2.pid
   133167      4 -rw-r--r--   1 root     root             2 Aug 15 08:54 /root/.pm2/pids/API-1.pid
   132991      4 -rw-r--r--   1 root     root            13 Aug 15 08:54 /root/.pm2/touch
   133163      0 srwxrwxr-x   1 root     root             0 Aug 15 08:54 /root/.pm2/rpc.sock
 15878705      4 drwxr-xr-x   2 root     root          4096 Aug 15 08:54 /root/.pm2/modules
  • similar issue: #3384 , #3440

How could we reproduce this issue?

Run PM2 in docker , using pm2-runtime binary with following process file

  • Docker entrypoint: CMD [ "pm2-runtime", "start", "ecosystem.config.js", "--env", "production" ]
  • and process file:
cat /app/ecosystem.config.js
module.exports = {
  apps: [{
    name: 'API',
    script: 'dist/index.js',
    instances: -1,
    exec_mode: 'cluster',
    autorestart: true,
    env: {
      NODE_ENV: 'development',
    },
    env_production: {
      NODE_ENV: 'production',
    },
  }],
}

Supporting information

$ pm2 report
--- PM2 report ----------------------------------------------------------------
Date                 : Mon Aug 17 2020 09:05:13 GMT+0000 (GMT)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.4.0
node version         : 12.18.2
node path            : not found
argv                 : /usr/local/bin/node,/usr/local/bin/pm2-runtime,start,ecosystem.config.js,--env,production
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
uptime               : 2890min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.4.0
node version         : 12.18.2
node path            : not found
argv                 : /usr/local/bin/node,/usr/local/bin/pm2,report
argv0                : node
user                 : undefined
uid                  : 0
gid                  : 0
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel Xeon E312xx (Sandy Bridge)
cpus nb              : 4
freemem              : 336703488
totalmem             : 4147662848
home                 : /root
===============================================================================
--- PM2 list -----------------------------------------------
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒           ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒          ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
▒ 0   ▒ API    ▒ default     ▒ 2.9.4-▒ ▒ cluster ▒ 19       ▒ 2D     ▒ 0    ▒ online    ▒ 4%       ▒ 118.7mb  ▒ root     ▒ disabled ▒
▒ 1   ▒ API    ▒ default     ▒ 2.9.4-▒ ▒ cluster ▒ 26       ▒ 2D     ▒ 0    ▒ online    ▒ 11.4%    ▒ 120.0mb  ▒ root     ▒ disabled ▒
▒ 2   ▒ API    ▒ default     ▒ 2.9.4-▒ ▒ cluster ▒ 33       ▒ 2D     ▒ 0    ▒ online    ▒ 7.4%     ▒ 116.6mb  ▒ root     ▒ disabled ▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
===============================================================================
--- Daemon logs --------------------------------------------

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the pm2-runtime entry point and the ecosystem.config.js process file shown in the report, using cluster mode inside Docker. Inspect how PM2 handles cluster output and configured log files, then verify that application logs go only to standard output without growing files under /root/.pm2/logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, javascript, node.js
Domain
cli, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.