Unitech / Unitech/pm2

Fix: pm2 on Windows - pm2 restart not always kill old process

Open
#5,459 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

Hello PM2 team,

During the tests I found why on the Windows sometimes after
pm2 restart
application starts more then one process.

Looks like the issue is in the function God.checkProcess.

Process.kill function does not always give the correct results. Sometimes the process can’t respond but the process is still alive.
Using the “tasklist” command for Windows solved this issue.

My MR with the fix: https://github.com/Unitech/pm2/pull/5458

This solution looks not perfect but I did a lot of tests (more than 500) restart and works very well.
Please send me confirmation if you can add this fix to the main source code.

Thanks

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 with the God.checkProcess function and inspect the linked pull request #5458 for the proposed Windows-specific fix. Reproduce pm2 restart behavior on Windows and verify that the old process is no longer running after repeated restarts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.