Yarkon Server – Production
When the time comes to set up the server for production, you want to ensure that it will run reliably, and would survive server reboots or application crashes.
The recommended method to ensure that is to use a process manager. In our server set up we use PM2, and recommend you do the same. PM2 is free to use and easy to install.
To run Yarkon Server with PM2, follow the Quick Start to get it installed, and ensure that it runs as a service so that it automatically restarts, using the
pm2 startup command. Note that PM2 requires NodeJS to be installed on the server as well.
You need a configuration file to run Yarkon. An example similar to what we use in our installs is:
You can use the
env section to pass optional parameters, such as the S3 API credentials. Note that in a production set up, it is common to run a web server application under port 80 and since PM2 runs as a service, it can do it.
If you save your PM2 configuration file under
yarkon-server.pm2.json, you can then run it using
PM2 offers you great control over the Yarkon Server process set up, so be sure to read at least the Quick Start to ensure you are familiar with all options.
Using a script
There are different ways to accomplish the same without installing any additional software. One example of a script that will restart the application on crash is presented in this Stack Overflow answer.