Unitech / Unitech/pm2

Do not start again the process via API if it's the same

Open
#4,837 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

I have started using the PM2 API so that I can start/stop processes based on remote signals. However, I was looking for a way to cross-check whether a process with the same arguments is already running, so that I would not have to start or restart it again, similar to what a pm2 start ecosystem.config.js. does. Currently, the pm2.start() always restarts the application, which might cause unnecessary restarts.

As part of my solution, I am trying to cross-check whether that process exists, and if its arguments are the same as the new ones. However, although the returning object does contain the args and env in the pm2_env, they are not mentioned neither in the docs nor in the Typescript definitions. Are those properties unstable? Is there any plan to add them to the docs?

Is there any plan to add an option to pm2.start() that checks if the process is different than the one already running?

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

Start at the pm2.start() API and the TypeScript definitions, then inspect how the returned pm2_env exposes args and env. Done requires a decided scope for avoiding redundant starts and for documenting or typing those properties, followed by corresponding API or definition changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.