-
Notifications
You must be signed in to change notification settings - Fork 5
2. Installing PM2
In this tutorial you will install PM2. PM2 is an application that makes running a Node.js server easier. It has many helpful features, including the following:
- Starting the server automatically at boot
- Restarting the server if it crashes
- A web monitoring site where you can see information on your process
-
These instructions are written for Debian-based Linux distributions (Debian, Ubuntu, Raspbian...). You may need to change some of the commands for them to work in other Linux distros, and Windows is unsupported and will most likely not work.
-
You need a Hermes server already running in order to follow these instructions! Follow guide #1 to host your own server.
Since PM2 is an NPM module, it is easily installed using it:
sudo npm install pm2@latest -g
To verify PM2 was installed successfully, enter the following command:
pm2 --version
If it shows you the version, then you installed it correctly.
Enter the folder where you have Hermes installed, and enter this command to add your Hermes server to PM2's process list:
pm2 start server.js --name "Hermes Server"Now, if you enter pm2 list you should see an entry for your Hermes server.
Enter these commands to setup autoboot:
pm2 save
pm2 startup
You will see a command printed at the bottom of the output. Copy it and run that command.
- Create an account on app.pm2.io.
- When you're done, it'll ask you to configure your account.
Choose "Your Server", and click Continue. - You'll see three terminal commands. Copy the middle one and paste it into your server.
(Replace MACHINE_NAME with the name you want your server to show up as). - When you're done, refresh the page. It'll show you information from your server.
PM2 has many different commands. Some of the most important ones are:
pm2 start "Hermes Server" - Starts the server.
pm2 stop "Hermes Server" - Stops the server.
pm2 restart "Hermes Server" - Restarts the server.
pm2 logs - Shows server logs.
You should have your Hermes server running through PM2!
- If you don't, go back and make sure you did everything correctly.
- If you do, you can continue to the next step