Running a supervisord daemon as non-root

There are often cases where we cannot setup a service as the root user. In those cases, it can be handy to set up supervisord for your user.The first thing we’ll need is a supervisord.conf file. I found the following setup to work well for me:

[unix_http_server]
file=%(here)s/supervisor.sock

[supervisord]
logfile=%(here)s/logs/supervisord.log
logfile_maxbytes=10MB
logfile_backups=5
pidfile=%(here)s/supervisord.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl = unix://%(here)s/supervisor.sock

[include]
files=%(ENV_HOME)/applications/*/private_html/supervisord.conf

Have a look at the docs for everything that’s available.

I recommend creating the following directories to store everything supervisord related:

mkdir -p ${HOME}/supervisord/logs

Put the supervisord.conf file in the directory created, i.e, ${HOME}/supervisord/supervisord.conf.

You’re now ready to start the daemon with

/usr/bin/supervisord -c ${HOME}/supervisord/supervisord.conf

You can then view logs at ${HOME}/supervisord/logs/supervisord.log and view status of programs with supervisorctl:

/usr/bin/supervisorctl -c ${HOME}/supervisord/supervisord.conf

After adding a program in one of the sub-directories in applications, run the following to make supervisord see the changes:

/usr/bin/supervisorctl -c ${HOME}/supervisord/supervisord.conf update

To stop the daemon, use the following:

kill $(supervisorctl -c ${HOME}/supervisord/supervisord.conf pid)