Install Supervisord on Debian and Ubuntu

To run background scripts, Supervisord is a powerfull and easy to install tool. Circus is a good alternative, but I didn’t test it.

This is a small tutorial to install Supervisord on Debian and Ubuntu :

Install

Install supervisor with PIP

 # pip install supervisor

Configuration

Create en configuration file, for example in /home/<user>/supervisord.conf

example :

[unix_http_server]
file=<pathtosock>/supervisord.sock # ex: /var/run/supervisord.sock

[inet_http_server]
port=*:9000
username=default
password=default

[supervisord]
logfile=<pathtologfile>/supervisord.log # ex: /var/log/supervisord/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=<pathtopidfile>/supervisord.pid # ex: /var/run/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
user=<user> # (if possible, not root)
#environment=

[supervisorctl]
serverurl=unix://<pathtosock>/supervisord.sock # ex: /var/run/supervisord.sock

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

[program:project_server]
directory=<pathtoapplication> # ex: /home/<user>/python/
command=<command> # ex: /usr/bin/python loop.py
stdout_logfile=<pathtoapplicationlog>/stdout.log # ex: /var/log/<application>/stdout.log
stdout_logfile_maxbytes=5MB
stdout_logfile_backups=10
stdout_capture_maxbytes=5MB
stderr_logfile=<pathtoapplicationlog>/stderr.log # ex: /var/log/<application>/stderr.log
stderr_logfile_maxbytes=5MB
stderr_logfile_backups=10
stderr_capture_maxbytes=5MB

Launch supervisord daemon :
sudo supervisord -c supervisord.conf

verify permission
ex:
chmod -R 777 /var/log/<application>/
chmod -R 777 /var/log/supervisord/

Start application:
Connect on interface :
http://<domain>:9000
login with default/default
Then press “start”
Process must have a loop

Raphaël has written 45 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>