pm2-installer icon indicating copy to clipboard operation
pm2-installer copied to clipboard

State is now: Stopped

Open nrcionline opened this issue 2 years ago • 13 comments

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.

nrcionline avatar Jul 17 '22 00:07 nrcionline

I have the same issue in a Windows Server 2019

Dr-NULL avatar Aug 16 '22 16:08 Dr-NULL

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

linchiyu avatar Aug 17 '22 18:08 linchiyu

Same here.

Alynva avatar Aug 18 '22 16:08 Alynva

Same here..

taieb-tk avatar Aug 31 '22 21:08 taieb-tk

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

Sandro-Sousa avatar Sep 01 '22 19:09 Sandro-Sousa

@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 avatar Sep 15 '22 00:09 redevill

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...

redevill avatar Sep 15 '22 01:09 redevill

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 avatar Sep 15 '22 18:09 Sandro-Sousa

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

Sandro-Sousa avatar Sep 15 '22 18:09 Sandro-Sousa

@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.

redevill avatar Sep 15 '22 20:09 redevill

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.

SnippetsUnlimited avatar Oct 12 '22 13:10 SnippetsUnlimited

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.

DeanB2015 avatar Jun 08 '23 14:06 DeanB2015

@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 👍

aquiab avatar Nov 24 '23 03:11 aquiab