Unitech / Unitech/pm2

Namespacing doesn't work when using Popen in a runned pm2

Open
#4,778 13 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?

Hello guys!

I have worked abit with name spacing and I have realized that if you try to do a namespacing inside a script that is runned by pm2 and Popen etc:

Popen(f"pm2 start test.py --name test1 --namespace testing --interpreter=python3", shell=True).communicate()

That will not create a namespace for the name testing.

How could we reproduce this issue?

test_new.py - Run this FIRST with pm2 start test_new.py --interpreter=python3

from subprocess import Popen

Popen(f"pm2 start test.py --name test1 --namespace testing --interpreter=python3", shell=True).communicate()

test.py

print("hello world!")

What should happend is that test.py should have the name = test and namespace = testing but it says default instead.

Excepted result:

--- PM2 report ----------------------------------------------------------------
Date                 : Sun Jul 12 2020 15:09:14 GMT+0200 (GMT+02:00)
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 4.4.1
node version         : 12.18.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : autosnkr
uid                  : 1000
gid                  : 1000
uptime               : 17535min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 4.4.1
node version         : 12.18.1
node path            : /usr/bin/pm2
argv                 : /usr/bin/node,/usr/bin/pm2,report
argv0                : node
user                 : autosnkr
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Core(TM) i7-8700T CPU @ 2.40GHz
cpus nb              : 12
freemem              : 9361747968
totalmem             : 16616714240
home                 : /home/autosnkr
===============================================================================
--- PM2 list -----------------------------------------------
┌─────┬───────────────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name                              │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼───────────────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 297 │ test		  	          │ default     │ N/A     │ fork    │ 5234     │ 10m    │ 3    │ online    │ 0%       │ 13.5mb   │ autosnkr │ disabled │
└─────┴───────────────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list running is not in sync with saved list. aplace hoopz paulfriends solestory streetlab differs. Type 'pm2 save' to synchronize.
===============================================================================
--- Daemon logs --------------------------------------------
/home/autosnkr/.pm2/pm2.log last 20 lines:
PM2        | 2020-07-12T14:58:47: PM2 log: App [test:297] starting in -fork mode-
PM2        | 2020-07-12T14:58:47: PM2 log: App [test:297] online

Supporting information

I love you guys for what you guys have done <3

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

Run the supplied test_new.py and test.py commands, then compare the resulting pm2 list output with the expected testing namespace. Trace how the CLI handles --namespace when PM2 is started through Python Popen; done means the launched test process appears with name test in namespace testing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, python
Domain
backend, cli
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.