jessety / pm2-installer

Install PM2 offline as a service on Windows or Linux. Mostly designed for Windows.
MIT License
495 stars 50 forks source link

Error caught while calling pidusage | TypeError: One of the pids provided is invalid #76

Open Drift91 opened 1 year ago

Drift91 commented 1 year ago

Description

I seem to be unable to use this daemon. When I try to run my Node app with it, it never runs and pm2 logs gives the following

PM2      | Error caught while calling pidusage
PM2      | TypeError: One of the pids provided is invalid
PM2      |     at get (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pidusage\lib\stats.js:78:23)
PM2      |     at pidusage (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pidusage\index.js:30:5)
PM2      |     at Object.getMonitorData (C:\ProgramData\npm\npm\node_modules\pm2\lib\God\ActionMethods.js:60:5)
PM2      |     at tasks (C:\ProgramData\npm\npm\node_modules\pm2\lib\Worker.js:150:9)
PM2      |     at Domain.<anonymous> (C:\ProgramData\npm\npm\node_modules\pm2\lib\Worker.js:193:7)
PM2      |     at Domain.run (node:domain:389:15)
PM2      |     at Timeout.wrappedTasks [as _onTimeout] (C:\ProgramData\npm\npm\node_modules\pm2\lib\Worker.js:192:7)
PM2      |     at listOnTimeout (node:internal/timers:564:17)
PM2      |     at process.processTimers (node:internal/timers:507:7)
PM2      | Error caught while calling pidusage
PM2      | TypeError: One of the pids provided is invalid
PM2      |     at get (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pidusage\lib\stats.js:78:23)
PM2      |     at pidusage (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pidusage\index.js:30:5)
PM2      |     at getMonitorData (C:\ProgramData\npm\npm\node_modules\pm2\lib\God\ActionMethods.js:60:5)
PM2      |     at Server.onmessage (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pm2-axon-rpc\lib\server.js:104:6)
PM2      |     at RepSocket.emit (node:events:513:28)
PM2      |     at RepSocket.emit (node:domain:489:12)
PM2      |     at Parser.<anonymous> (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\rep.js:51:15)
PM2      |     at Parser.emit (node:events:513:28)
PM2      |     at Parser.emit (node:domain:489:12)
PM2      |     at Parser._write (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\amp\lib\stream.js:91:16)

Steps to Reproduce

  1. Fresh install of pm2-installer
  2. Navigate to apps folder
  3. Execute the following: pm2 start npm --name SnailyCADv4 -- run start

Environment

npm run info for some reason throws the error, Missing script: "info" Didn't realize it had to be run in the repo folder. Output:

> pm2-installer@3.4.3 info
> node ./src/bundle-info/current.js

Running on: 2/13/2023, pm2-installer 3.4.3 with node v18.13.0 and npm 9.4.2 on win32-10.0.20348.
sheldonpang commented 1 year ago

Having same issue

Running on: 2/20/2023, pm2-installer 3.4.3 with node v18.14.1 and npm 9.3.1 on win32-10.0.22621.

Choppel commented 1 year ago

Hello, I had the same issue a couple of minutes ago. For me the problem was an error with the cwd parameter in the ecosystem.config.js file of a program that I wanted pm2 to start. The directory simply did not exist. Because of the error pm2 did not actually start my program. With version 3.4.2 of pm2-installer the output of "pm2 status" for my program was "online" although it was not really started. With version 3.4.0 of pm2-installer it actually showed "errored" when calling "pm2 status". So the message "One of the pids provided is invalid" is somewhat correct because there is no pid that could be used. But this seems more like an issue with pm2. I found out about the error only by opening C:\ProgramData\pm2\service\service.log. There it showed some ENOENT messages for my program.

@Drift91 I don't know what the problem with your example could be, but maybe looking at the log file mentioned above might help.

Hope this helps.

Choppel commented 1 year ago

@sheldonpang @Drift91 Did my comment help you?

dlscott12 commented 1 year ago

@Drift91 @Choppel @sheldonpang I had the same issue with "Error caught while calling pidusage" and "TypeError: One of the pids provided is invalid" during reboot. I ended up changing the "Log on as" user for the PM2 Service to a valid user (administrator) and now my PM2 apps all restart during reboot. YEAH ;-)

Hope this helps.

Spent hours tweeking with no luck, but had this nagging suspicion that it was security/permission related.

image

Ildarik commented 1 year ago

I had same issue and fixed it by changing Log on as: "Local System account"