name: Deployment with Supervisord
sort: 2
Supervisord
Supervisord is a very useful process manager implemented in Python. Supervisord can change your non-daemon application into a daemon application. The application needs to be a non-daemon app. So if you want to use Supervisord to manage nginx, you need to set daemon off to run nginx in non-daemon mode.
Install Supervisord
install setuptools
wget https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.eggsh setuptools-0.6c11-py2.7.eggeasy_install supervisorecho_supervisord_conf >/etc/supervisord.confmkdir /etc/supervisord.conf.d
config
/etc/supervisord.conf[include]files = /etc/supervisord.conf.d/*.conf
Create new application to be managed
cd /etc/supervisord.conf.dvim beepkg.conf
Configurations:
[program:beepkg]directory = /opt/app/beepkgcommand = /opt/app/beepkg/beepkgautostart = truestartsecs = 5user = rootredirect_stderr = truestdout_logfile = /var/log/supervisord/beepkg.log
Supervisord Manage
Supervisord provides two commands, supervisord and supervisorctl:
- supervisord: Initialize Supervisord, run configed processes
- supervisorctl stop programxxx: Stop process programxxx. programxxx is configed name in [program:beepkg]. Here is beepkg.
- supervisorctl start programxxx: Run the process.
- supervisorctl restart programxxx: Restart the process.
- supervisorctl stop groupworker: Restart all processes in group groupworker
- supervisorctl stop all: Stop all processes. Notes: start, restart and stop won’t reload the latest configs.
- supervisorctl reload: Reload the latest configs.
- supervisorctl update: Reload all the processes who’s config has changed.
Notes: The processes stopped by
stopmanually won’t restart after reload or update.
