jessety / pm2-installer

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

State is now: Stopped #69

Open nrcionline opened 2 years ago

nrcionline commented 2 years ago

After running this on windows server 2022 (including the configure options), all I get is: State is now: Stopped printing endlessly to the powershell window. I tried to manually start the PM2 process, but it won't start.

Dr-NULL commented 2 years ago

I have the same issue in a Windows Server 2019

linchiyu commented 2 years ago

Restarting the computer solved this issue for me, this problem happened after I installed pm2-installer, removed it and then installed it again

Alynva commented 2 years ago

Same here.

taieb-tk commented 2 years ago

Same here..

Sandro-Sousa commented 2 years ago

for those who are experiencing the problem of the service stopped, go to Services > in the Log On tab, Set as local system account.

redevill commented 2 years ago

@Sandro-Sousa - Tried changing the service to local system account. Then the service was able to start. However after a reboot of the system, when I try to perform a pm2 list:

My understanding of the service is to provide a restart of pm2 after a reboot - currently I can't get this to work.

C:\Users\zenwa>pm2 list connect EPERM //./pipe/rpc.sock [PM2] Spawning PM2 daemon with pm2_home=C:\ProgramData\pm2\home node:events:505 throw er; // Unhandled 'error' event ^

Error: connect EPERM //./pipe/rpc.sock at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) Emitted 'error' event on ReqSocket instance at: at Socket. (C:\ProgramData\npm\npm\node_modules\pm2\node_modules\pm2-axon\lib\sockets\sock.js:201:49) at Socket.emit (node:events:527:28) at emitErrorNT (node:internal/streams/destroy:157:8) at emitErrorCloseNT (node:internal/streams/destroy:122:3) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4048, code: 'EPERM', syscall: 'connect', address: '//./pipe/rpc.sock' }

redevill commented 2 years ago

After reboot, if I shut the service down, and then issue the Pm2 list command manually:

C:\Users\zenwa>pm2 list [PM2] Spawning PM2 daemon with pm2_home=C:\ProgramData\pm2\home [PM2] PM2 Successfully daemonized

Then PM2 starts successfully without the processes... [PM2][WARN] Current process list is not synchronized with saved list. App app differs. Type 'pm2 save' to synchronize.

At this point if I restart the service, the expected processes running under pm2 also come back. Possibly priv issue with the service? It is unable to start / deamonize pm2? after reboot...

Sandro-Sousa commented 2 years ago

you need to give admin permissions to access the folder where pm2 was installed globally, follow this tutorial:https://blog.cloudboost.io/nodejs-pm2-startup-on-windows-db0906328d75

Sandro-Sousa commented 2 years ago

if you already have the pm2 installer disregard the last two steps about the other tools

redevill commented 2 years ago

@Sandro-Sousa - just discovered the problem(FYI for NVM users): I am using nvm, and was using the default location, which is user specific. Changed the nvm install location to ProgramData\nvm ... also made sure all installation was done with admin. This change allowed the service to install normally (no endless "server state") AND start normally, and to come back after reboot. The last tidbit - unless you use an admin window to do the "pm2 list" after the reboot, you still get the above error.

SnippetsUnlimited commented 2 years ago

When the PM2 service is stopped and you run the command line "pm2 start myapp", this starts the pm2 daemon. If you try to start the PM2 service while running the daemon the service would keep crashing. For Windows, you have to do the following steps in order: 1 - Restart machine. 2 - Run PM2 Windows Service through service console. 3 - Run command line "pm2 start myapp" 4 - Run command line "pm2 save"

This should start the service, register and run your app. Any further restarts should start your pm2 windows service as expected.

DeanB2015 commented 1 year ago

Adding the Local Service username to the nodejs folder > Properties > Security solved this for me. Local Service is used on my PM2 Windows Services > Properties > Log On.

aquiab commented 1 year ago

@Sandro-Sousa - just discovered the problem(FYI for NVM users): I am using nvm, and was using the default location, which is user specific. Changed the nvm install location to ProgramData\nvm ... also made sure all installation was done with admin. This change allowed the service to install normally (no endless "server state") AND start normally, and to come back after reboot. The last tidbit - unless you use an admin window to do the "pm2 list" after the reboot, you still get the above error.

thank you, this was the problem for me too, just reinstalled nvm to c:/program files and it worked fine 👍