Below is a quick run of configuring NodeJS with Supervisord.
Here is the base config for supervisord.conf on Gentoo:
[supervisord] [unix_http_server] file=/var/run//supervisor.sock ; (the path to the socket file) chmod=0700 ; sockef file mode (default 0700) [supervisorctl] serverurl=unix:///var/run//supervisor.sock ; use a unix:// URL for a unix socket [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [include] files = /etc/supervisor/conf.d/*.conf
The per-application configuration files are held in /etc/supervisor/conf.d/*.conf per the [include] block at the bottom of /etc/supervisord.conf.
Here is a per-application configuration file of Ghost CMS (which this blog is using!):
[program:ghost] command = node /path/to/ghost/index.js directory = /path/to/ghost user = myuser autostart = true autorestart = true stdout_logfile = /var/log/supervisord/ghost.log stderr_logfile = /var/log/supervisord/ghost_err.log environment = NODE_ENV="production"
Make sure to replace the command, directory and user values with appropriate values for your environment. The rest of the values are also configurable.
Once you have configured the per-application file you can start supervisord:
If you already have supervisord started, you can run the following to start the ghost process;
supervisorctl start ghost
Congratulations, you have supervisord controlling NodeJS!
I will be doing another post soon on setting up NodeJS with pm2 for better process management, control and performance.