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

PM2 couldn't run the app and the app ends up in "errored" status #19

Open kondekar opened 3 years ago

kondekar commented 3 years ago

Description PM2 couldn't run the app and the app ends up in "errored" status

Steps to Reproduce

  1. Installed Node.js LTS 64 bit version on Windows Server 2012 R2
  2. Downloaded latest PM2-installer
  3. Ran following in order npm run configure npm run configure-policy npm run setup
  4. Ran server with node index.js Everything runs fine.
  5. Ran server with pm2 start index.js. The server starts in "errored" status. Logfile is empty
  6. however I noticed the following error in service.log in C:\ProgramData\pm2\service
2021-03-23T23:13:56: PM2 log: App [server-plugin:0] starting in -fork mode-
2021-03-23T23:13:56: PM2 log: App [server-plugin:0] online
ERROR: 2021-03-23T23:13:56: PM2 error: Error: spawn node ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
3/23/2021, 11:13:56 PM: default/server-plugin@N/A - start - MANUAL
ERROR: 2021-03-23T23:13:56: PM2 error: Cancelling versioning data parsing

Environment

pm2-installer@3.1.4 info C:\Users\deeptarget\pm2-installer-main node ./src/bundle-info/current.js

Running on: 3/23/2021, pm2-installer 3.1.4 with node v14.16.0 and npm 6.14.11 on win32-6.3.9600.

jkamleh commented 3 years ago

I had a similar issue, not the same error but worth a shot, have you tried giving NT AUTHORITY\Local Service user permissions (in my case I gave it full control, because I needed to modify/write to the directory).

Also, I downloaded PSTools (https://docs.microsoft.com/en-us/sysinternals/downloads/pstools) and run the following to give me a powershell window running as NT AUTHORITY\Local Service: .\PsExec.exe -i -u 'NT AUTHORITY\Local Service' powershell

If you then navigate to your project root in the new powershell window and run: pm2 start index.js

It should be listed as the local service user now. Hopefully any of the above helps :)

kondekar commented 3 years ago

@jkamleh Thanks for giving a good direction to think. I gave full control to the root folder of App to Local Service. I also launched PowerShell running as NT AUTHORITY\Local Service. That made PM2 launch the app with status as online but the next moment status became "errored". The log file has this error - "Script %s had too many unstable restarts (%d). Stopped." Any idea further?

tasop-rsconnect commented 3 years ago

Having the same issue.

PM installer 3.1.5 Node v10.18.0 NPM 6.13.4 Windows Server 2012 R2

kondekar commented 3 years ago

Please check out my interim solution at https://stackoverflow.com/questions/66765092/pm2-couldnt-start-the-app-and-the-app-ends-up-in-errored-status/67120616#67120616