PM2 should then launch after the reboot, and also start the apps that were monitored by PM2 when the “pm2 save” was issued. Mission accomplished. Run PM2 as a Windows service. The trick of using Windows scheduler to start and keep PM2 alive works, but is not really very elegant. A better solution would be to run PM2 as a Windows. Indeed, maxrestart concerns consecutives unstable restarts (restarts happening in less than 1sec interval between them). Maxrestarts defaults to 15. I will implement -no-restart flag soon. PM2 comes with a default feature to create startup scripts for multiple initialized systems. These startup-scripts are executed whenever a system is booted which in turn restarts the PM2 process itself. This PM2 process restarts the listed jobs and helps in resumption of the applications running on the server.
- Pm2 Start On Restart
- Pm2 Start On Reboot System
- Pm2 Start On Reboot Device
- Pm2 Start On Reboot Iphone X
- Pm2 Startup Windows
- Pm2 Start On Reboot Windows
In seconds, this Quick Start tutorial will show you how to set up to production a Node.js application with PM2.
Installation
With npm:
With yarn:
With debian, use the install script:
With docker, follow this tutorial.
CLI autocompletion
Complete your installation with the CLI autocompletion:
Manage multiple processes
Pm2 Start On Restart
PM2 keeps a list of your processes to be able to start, restart and stop them easily.
All your apps are started in the background, letting you access to the command line. Use the PM2 CLI to interact with your apps.
Process list
Add processes to your process list with the start and delete commands.
Default process name is the filename without .js
(eg: app
for app.js
). Use --name
or -n
to change.
Routine
Once in your process list, use the process name to interact with your application.
You can then setup a startup script, to automatically start your process list across machine restarts.
Access your logs
Access your logs in realtime with pm2 logs app
.
Consult your logs history files in the ~/.pm2/logs
folder.
Clusterize
Pm2 Start On Reboot System
The cluster mode scales your app accross all CPUs available, without any code modifications.
Before using the load balancer, make sure your application is stateless, meaning that no local data is stored in the process (sessions/websocket connections, session-memory and related).
To start in cluster mode, pass the -i option followed by the number of clusters that you want:
Pm2 Start On Reboot Device
or, to automatically detect number of CPUs available:
Use reload instead of restart for 0-seconds downtime reloads:
Next Steps
Questions?
We are always happy to help with questions you might have. Use the search or check out the FAQ. You can also post questions or comments on the PM2 github repository.
Pm2 Start On Reboot Iphone X
- Install Git
- Install Nginx
- Setup Nginx as a Reverse Proxy for your Node.js Application
- Install Node using NVM
- Install PM2
- Run a Dummy API Server Using express
- Start the Server using PM2
- Auto Start PM2 after a server reboot.
Login to Ec2 Instance - ssh ec2-user@54.221.355.461 -i ~/.ssh/temp-personal.pem
This script is run by root user. But some part (subscript
) of it is run as ec2-user
so it can install node.js
without sudo.
Pm2 Startup Windows
Don't forget to allow HTTP Port 80 in your Security Group.
The following script will completely overwrite your EC2 server's NGINX configuration to setup a reverse proxy.
Don't forget to add a backslash if you want to use $ inside the
subscript
.
Pm2 Start On Reboot Windows
You can check the output of this script cat /var/log/cloud-init-output.log
or cat /var/log/cloud-init.log
.