Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App shows as started on pm2 ls but it's frozen and doesn't get a PID. #88

Open
Javihache opened this issue Aug 21, 2023 · 5 comments
Open

Comments

@Javihache
Copy link

Description

After installing pm2-installer following the instructions (npm run configure && npm run setup), I get an ENOENT error when installing pm2-logrotate (probably unrelated). However when I try to start my application, it shows as a process running on pm2 ls but the memory is 0B and the application doesn't start.

I tried removing pm2-installer and re-installing to no avail.

If I remove pm2-installer and install npm i -g pm2 and then start the app with pm2 start app.js then the app starts all good.

Steps to Reproduce

  1. Install pm2-installer
  2. launch app with pm2 start app.js
  3. check pm2 ls and see the app running but no PID and no memory usage.

Environment

Running on: 21/08/2023, pm2-installer 3.4.3 with node v18.17.1 and npm 9.6.7 on win32-10.0.22621.

@Javihache
Copy link
Author

This is Windows 11. Experienced this same thing on several machines.

@Javihache
Copy link
Author

Javihache commented Aug 22, 2023

Ok, I figured out the problem. It's a permissions problem. For some reason, if I change the Service to use my Windows User to start, then the app starts correctly. Is there a way to fix this?

The error I get is as follows:

2023-08-22T12:09:01: PM2 error: Error: spawn node ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) 2023-08-22T12:09:01: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:01: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:07: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:07: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:07: PM2 error: Error: spawn node ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) 2023-08-22T12:09:07: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:07: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:31: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:31: PM2 error: TypeError: One of the pids provided is invalid 2023-08-22T12:09:31: PM2 error: Error caught while calling pidusage 2023-08-22T12:09:31: PM2 error: TypeError: One of the pids provided is invalid

If I add Local Service as owner of the folder in which my app is installed, I can start the app but it errors directly.

I actually needed to give Local Service Permissions to the containing folder where the app was installed (it was in a folder inside the $HOME folder of the user). That's what solved the issue.

Anyone has any idea how to avoid this problem? Installing outside the home folder maybe?

@Javihache
Copy link
Author

Javihache commented Aug 22, 2023

The problem arises if the application is located in the $HOME folder of a user. Local Service has no permissions by default to access that folder and the application will not start. I am guessing this is some typical "Windows" BS that can't be changed or fixed.

I am using a .ps1 script to install my application on customer's computers, but I cannot forbid them to choose a folder inside their $Home folder. I guess I'll try to add permissions conditionally to the folder in the case that the user installs inside the home folder.

@theShuker
Copy link

Took me a couple of hours to find this out! Would be good if this information was added as a notice to README!

@webhype
Copy link

webhype commented Jun 8, 2024

This problem is not just "Windows BS". I wish it were. Same happens on Mac OS and Debian / Ubuntu etc. In the past, deleting the ~/.pm2 folder altogether helped but I have a case where it makes no difference. This problem has been documented here for years and no fix. At least pm2 could catch this exception and show the service as failed, but no, it shows it as running (green) but PID n/a but 0% cpu and 0b mem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants