-
Notifications
You must be signed in to change notification settings - Fork 1
Keep stormnode alive
There are several methods for making a storm node always running. The most common is to run it as a service, although it is the standard way we recommend using supervisor.
Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems. It was inspired by the following:
It is often inconvenient to need to write rc.d scripts for every single process instance. rc.d scripts are a great lowest-common-denominator form of process initialization/autostart/management, but they can be painful to write and maintain. Additionally, rc.d scripts cannot automatically restart a crashed process and many programs do not restart themselves properly on a crash. Supervisord starts processes as its subprocesses, and can be configured to automatically restart them on a crash. It can also automatically be configured to start processes on its own invocation.
source http://supervisord.org/introduction.html
Supervisor can be installed with PIP (Python Package Installer):
pip install supervisor
Depending on the permissions of your system’s Python, you might need to be the root user to install Supervisor successfully using pip.
The programs are given to Supervisor through configuration files, which inform it of the executable to run, any environmental variables, and how output should be handled.
The program configuration files for Supervisor programs are found in the /etc/supervisor/conf.d directory, normally with one program per file and a .conf extension. A simple configuration for stormnode, saved at /etc/supervisor/conf.d/stormnode.conf, would look like so
[program:stormnode]
directory=/home/stormnode
command=/home/stormnode/stormnode.js
autostart=true
autorestart=true
stderr_logfile=/var/log/stormnode.err.log
stdout_logfile=/var/log/stormnode.out.log
user=linuxuser
edit the configuration file by changing the installation path and username with your settings
Start stormnode with supervisor Once our configuration file is created and saved, we can inform Supervisor of our new program through the supervisorctl command. First we tell Supervisor to look for any new or changed program configurations in the /etc/supervisor/conf.d directory with:
sudo supervisorctl reread
Followed by telling it to enact any changes with:
sudo supervisorctl update
check stormnode is active
sudo supervisorctl status
you should read something like:
stormnode RUNNING pid 25277, uptime 1:53:49