Unitech / Unitech/pm2

pm2 save is saving in the wrong directory

Open
#4,918 0 comments 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?

$ pm2 -v
4.5.0
$ echo $PM2_HOME
/etc/pm2
$ pm2 save
[PM2] Saving current process list...
[PM2] Successfully saved in /etc/pm2/dump.pm2

pm2 save is not saving in $PM2_HOME/.pm2/ as specified in the docs, but in $PM2_HOME

This is very problematic, because pm2 startup will try to read the dump from $PM2_HOME/.pm2.

[PM2][ERROR] Failed to read dump file in /etc/pm2/.pm2/dump.pm2

How could we reproduce this issue?

npm install pm2 -g
pm2 start ecosystem.config.js
pm2 save

Supporting information

$ pm2 report
[PM2] Spawning PM2 daemon with pm2_home=/etc/pm2
[PM2] PM2 Successfully daemonized
[PM2][Module] Starting NPM module pm2-logrotate
[PM2][WARN] Applications pm2-logrotate not running, starting...
[PM2] App [pm2-logrotate] launched (1 instances)


--- PM2 report ----------------------------------------------------------------
Date                 : Fri Nov 13 2020 19:50:04 GMT+0000 (Coordinated Universal Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.0
node version         : 12.18.4
node path            : /usr/local/lib/node_modules/bin/pm2
argv                 : /usr/bin/node,/usr/local/lib/node_modules/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ubuntu
uid                  : 1000
gid                  : 1000
uptime               : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.0
node version         : 12.18.4
node path            : /usr/local/lib/node_modules/bin/pm2
argv                 : /usr/bin/node,/usr/local/lib/node_modules/bin/pm2,report
argv0                : node
user                 : ubuntu
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel Core Processor (Haswell, no TSX)
cpus nb              : 1
freemem              : 3095891968
totalmem             : 4026880000
home                 : /home/ubuntu
===============================================================================
--- PM2 list -----------------------------------------------
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
│ id │ name               │ mode     │ ↺    │ status    │ cpu      │ memory   │
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
Module
┌────┬────────────────────┬──────────┬──────────┬──────────┐
│ id │ name               │ status   │ cpu      │ mem      │
├────┼────────────────────┼──────────┼──────────┼──────────┤
│ 0  │ pm2-logrotate      │ online   │ 0%       │ 27.6mb   │
└────┴────────────────────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/etc/pm2/pm2.log last 20 lines:
PM2        | 2020-11-13T19:50:01: PM2 log: pid=2608 msg=process killed
PM2        | 2020-11-13T19:50:01: PM2 log: PM2 successfully stopped
PM2        | 2020-11-13T19:50:04: PM2 log: ===============================================================================
PM2        | 2020-11-13T19:50:04: PM2 log: --- New PM2 Daemon started ----------------------------------------------------
PM2        | 2020-11-13T19:50:04: PM2 log: Time                 : Fri Nov 13 2020 19:50:04 GMT+0000 (Coordinated Universal Time)
PM2        | 2020-11-13T19:50:04: PM2 log: PM2 version          : 4.5.0
PM2        | 2020-11-13T19:50:04: PM2 log: Node.js version      : 12.18.4
PM2        | 2020-11-13T19:50:04: PM2 log: Current arch         : x64
PM2        | 2020-11-13T19:50:04: PM2 log: PM2 home             : /etc/pm2
PM2        | 2020-11-13T19:50:04: PM2 log: PM2 PID file         : /etc/pm2/pm2.pid
PM2        | 2020-11-13T19:50:04: PM2 log: RPC socket file      : /etc/pm2/rpc.sock
PM2        | 2020-11-13T19:50:04: PM2 log: BUS socket file      : /etc/pm2/pub.sock
PM2        | 2020-11-13T19:50:04: PM2 log: Application log path : /etc/pm2/logs
PM2        | 2020-11-13T19:50:04: PM2 log: Worker Interval      : 30000
PM2        | 2020-11-13T19:50:04: PM2 log: Process dump file    : /etc/pm2/dump.pm2
PM2        | 2020-11-13T19:50:04: PM2 log: Concurrent actions   : 2
PM2        | 2020-11-13T19:50:04: PM2 log: SIGTERM timeout      : 1600
PM2        | 2020-11-13T19:50:04: PM2 log: ===============================================================================
PM2        | 2020-11-13T19:50:04: PM2 log: App [pm2-logrotate:0] starting in -fork mode-
PM2        | 2020-11-13T19:50:04: PM2 log: App [pm2-logrotate:0] online

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 PM2_HOME=/etc/pm2 using pm2 start ecosystem.config.js, pm2 save, and pm2 startup; compare the reported dump paths and the PM2 report output. Trace the pm2 save and pm2 startup entry points to determine why they resolve different locations, then verify that the dump is saved where startup reads it.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.