At a Windows AWS server i have a NODE app and i\'m using PM2 to launch the app
I have tried the NPMs: \"pm2-windows-startup\" and \"pm2-windows-service\"
But aft
I found this tutorial very useful: https://blog.cloudboost.io/nodejs-pm2-startup-on-windows-db0906328d75
the first approach using 'nssm' and a .bat file not worked for me, so I followed approach 2: "Solution2: Using pm2-windows-service"
However, as mentioned in other answers, the pm2-windows-service
has a bug,
which this fork solved:
https://www.npmjs.com/package/@innomizetech/pm2-windows-service
so instead of the old package:
npm install -g pm2-windows-service
use the new one:
npm install -g @innomizetech/pm2-windows-service
here a short summary of the tutorial:
npm i -g pm2
C:\Users\USER\.pm2
to C:\etc\.pm2
PM2_HOME
value: c:\etc\.pm2
pm2 start app.js --name=MY_API
.pm2 save
to create a dump of the current apps running.pm2 kill
and then pm2 resurrect
(app should be running, check with pm2 status
)now we need to perform the resurrect command at startup, so:
npm install -g @innomizetech/pm2-windows-service
pm2-service-install -n PM2 --unattended
thats it.