Unitech / pm2

Node.js Production Process Manager with a built-in Load Balancer.
https://pm2.keymetrics.io/docs/usage/quick-start/
Other
41.38k stars 2.61k forks source link

One of the provided PIDs are invalid when running script in another users directory #5750

Open crackedpotato007 opened 8 months ago

crackedpotato007 commented 8 months ago

## What's going wrong? Script doesn't start, no PID assigned in pm2 list. using no-daemon gives that error

How could we reproduce this issue?

Have the script in C:\Users\foo\Desktop and execute the script as the user bar using pm2 start C:\Users\foo\Desktop\index.js

Supporting information

I went through #5496 and the last comment, specifically moving the project to C: fixes the issue but moving the project is not feasible for my usecase.

--- PM2 report ----------------------------------------------------------------                                           Date                 : Fri Jan 26 2024 02:39:34 GMT+1100 (Australian Eastern Daylight Time)                               ===============================================================================                                           --- Daemon -------------------------------------------------                                                              pm2d version         : 5.2.2                                                                                              node version         : 20.10.0                                                                                            node path            : not found                                                                                          argv                 : C:\Program Files\nodejs\node.exe,C:\ProgramData\pm2\service\index.js                               argv0                : C:\Program Files\nodejs\node.exe                                                                   user                 : undefined                                                                                          uid                  : N/A                                                                                                gid                  : N/A                                                                                                uptime               : 65min                                                                                              ===============================================================================                                           --- CLI ----------------------------------------------------                                                              local pm2            : 5.2.2                                                                                              node version         : 20.10.0                                                                                            node path            : not found                                                                                          argv                 : C:\Program Files\nodejs\node.exe,C:\ProgramData\npm\npm\node_modules\pm2\bin\pm2,report            argv0                : node                                                                                               user                 : Administrator                                                                                      ===============================================================================                                           --- System info --------------------------------------------                                                              arch                 : x64                                                                                                platform             : win32                                                                                              type                 : Windows_NT                                                                                         cpus                 : AMD Ryzen 7 5800X 8-Core Processor                                                                 cpus nb              : 16                                                                                                 freemem              : 5209092096                                                                                         totalmem             : 103002312704                                                                                       home                 : C:\Users\Administrator                                                                             ===============================================================================                                           --- PM2 list -----------------------------------------------                                                              ┌─────┬───────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐                                                                                            │ id  │ name                      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │                                                                                            ├─────┼───────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤                                                                                            │ 3   │ server                    │ default     │ N/A     │ fork    │ N/A      │ 63m    │ 0    │ online    │ 0%       │ 0b       │ Adm… │ disabled │                                                                                                └─────┴───────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘                                                                                            Modules                                                                                                                   ┌────┬──────────────────────────────┬───────────────┬──────────┬──────────┬──────┬──────────┬──────────┬──────────┐       │ id │ module                       │ version       │ pid      │ status   │ ↺    │ cpu      │ mem      │ user     │       ├────┼──────────────────────────────┼───────────────┼──────────┼──────────┼──────┼──────────┼──────────┼──────────┤       │ 0  │ @jessety/pm2-logrotate       │ 2.7.1         │ 23340    │ online   │ 0    │ 0%       │ 0b       │ Adm… │           │ 2  │ @jessety/pm2-logrotate       │ 2.7.1         │ 17176    │ online   │ 0    │ 0%       │ 0b       │ Adm… │           │ 4  │ @jessety/pm2-logrotate       │ 2.7.1         │ 21348    │ online   │ 0    │ 0%       │ 0b       │ Adm… │           └────┴──────────────────────────────┴───────────────┴──────────┴──────────┴──────┴──────────┴──────────┴──────────┘       [PM2][WARN] Current process list is not synchronized with saved list. Type 'pm2 save' to synchronize.                     ===============================================================================                                           --- Daemon logs --------------------------------------------                                                          
crackedpotato007 commented 7 months ago

Sorry, for the broken formatting. Lost access to my account shortly after creating this issue. This issue occurs in 5.3.1 and not in 5.2.2

JeffEmery commented 7 months ago

I think I have the same issue. I'm using pm2-installer https://github.com/jessety/pm2-installer which creates a Windows service to run PM2 as LocalService. If I move the script to a root folder like C:\MyApp\index.js, it seems to work. I suspect the LocalService does not have access rights to the user folder C:\Users\jane...