Skip to content

Instantly share code, notes, and snippets.

@satishgunjal
Last active December 4, 2019 11:04
Show Gist options
  • Save satishgunjal/43ac8ca22e901f44097b25b16a0d9f8f to your computer and use it in GitHub Desktop.
Save satishgunjal/43ac8ca22e901f44097b25b16a0d9f8f to your computer and use it in GitHub Desktop.
PM2 Startup on Windows (Node.js)
Ref. https://blog.cloudboost.io/nodejs-pm2-startup-on-windows-db0906328d75
In above document Ref Section : [1b]> PM2 save
This section explains how to configure one application and save the configurations.
But if we run 'pm2 save' cmd it will override the previous configurations.
In order to start multiple applications together load all the applications using command 'pm2 reload ecosystem.config.js --env=production'
and then run 'pm2 save' command at the end. It takes a snapshot of currently running Node applications.
We can then restore these applications using 'pm2 resurrect'. Same command will be called during windows reboot.
To start the node apps on windows startup we are going to use [2b]> Solution2: Using pm2-windows-service
If setup stops at '? Perform environment setup (recommended)? Yes' follow below steps.
(I think it is because of old Inquirer version. After upgrading it to 5.0 or newer solved the problem for me.)
npm install -g npm-check-updates
cd %USERPROFILE%\AppData\Roaming\npm\node_modules\pm2-windows-service
ncu inquirer -u
npm install
After following above steps start again from this command- pm2-service-install -n PM2
Note: make sure you are in C drive when running this command "cd %USERPROFILE%\AppData\Roaming\npm\node_modules\pm2-windows-service"
else path wont change and rest of the command wont work
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment