Unitech / Unitech/pm2

Modules not saved in process list

Open
#5,195 1 comment 1 reaction 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?

Starting an application as pm2 module has some advantages over starting it as regular application. This e.g. allows installing an application published to a private registry like this pm2 install @company/my-application and easily change environment variables like this pm2 set @company/my-application:FOO bar. Apart from that, pm2 modules seem to work exactly like regular processes. However, modules don't seem to be considered in the process list when running pm2 save and therefore don't automatically restart when the server restarts. When I try to save the process list I get this message:

[PM2][WARN] PM2 is not managing any process, skipping save...
[PM2][WARN] To force saving use: pm2 save --force

Saving the process list with --force also only produces an empty process list when looking at the dump file afterwards. pm2 therefore doesn't start anything after server restarts unfortunately.

Is there a way of forcing the modules to be considered in the process list. If not, is there a convenient way of starting / installing an application from an npm registry just as with pm2 modules to overcome this problem?

How could we reproduce this issue?

Create a pm2 module, start only this module and save the process list after running the startup hook.

Supporting information

--- PM2 report ----------------------------------------------------------------
Date                 : Tue Oct 05 2021 11:27:00 GMT+0200 (Central European Summer Time)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.5.6
node version         : 14.17.0
node path            : not found
argv                 : /usr/local/src/node-v14.17.0/bin/node,/usr/local/src/node-v14.17.0/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : mmende
uid                  : 1000
gid                  : 1000
uptime               : 21461min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.5.6
node version         : 14.17.0
node path            : /usr/local/src/node/bin/pm2
argv                 : /usr/local/src/node-v14.17.0/bin/node,/usr/local/src/node/bin/pm2,report
argv0                : node
user                 : mmende
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
cpus nb              : 16
freemem              : 19743420416
totalmem             : 68719476736
home                 : /home/mmende
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬─────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                    │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
└─────┴─────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
Modules
┌────┬───────────────────────────────────────┬────────────────────┬───────┬──────────┬──────┬──────────┬──────────┬──────────┐
│ id │ module                                │ version            │ pid   │ status   │ ↺    │ cpu      │ mem      │ user     │
├────┼───────────────────────────────────────┼────────────────────┼───────┼──────────┼──────┼──────────┼──────────┼──────────┤
│ 1  │ @company/my-application               │ 3.0.2              │ 16648 │ online   │ 1    │ 0.1%     │ 63.0mb   │ mmende   │
└────┴───────────────────────────────────────┴────────────────────┴───────┴──────────┴──────┴──────────┴──────────┴──────────┘
===============================================================================
--- Daemon logs --------------------------------------------
/home/mmende/.pm2/pm2.log last 20 lines:
PM2        | 2021-09-21T09:12:19: PM2 log: App [@company/my-application:1] starting in -fork mode-
PM2        | 2021-09-21T09:12:19: PM2 log: App [@company/my-application:1] online

(...changed the module name to match the name in the examples for clarification)

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 by installing and starting a PM2 module, then running pm2 save after the startup hook setup. Trace the save and module process-list entry points; done means the module appears in the saved dump and is restored after a server restart.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.