Skip to content

Instantly share code, notes, and snippets.

@bububa
Created June 18, 2012 07:25
Show Gist options
  • Save bububa/2947281 to your computer and use it in GitHub Desktop.
Save bububa/2947281 to your computer and use it in GitHub Desktop.
Supervisord
REFERENCE: http://www.masnun.me/2011/11/02/gearman-php-and-supervisor-processing-background-jobs-with-sanity.html
apt-get install python-setuptools
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf
=============================================
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[program:gearman_worker]
command = php /var/code/xibao.com/index.php --uri=worker/worker
process_name = %(program_name)s_%(process_num)02d
numprocs = 4
autostart = true
autorestart = true
stdout_logfile = /var/log/gearman/worker.log
stdout_logfile_maxbytes=1MB
stderr_logfile = /var/log/gearman/worker_err.log
stderr_logfile_maxbytes=1MB
[program:gearman_init_merchant_keywords]
command = php /var/code/xibao.com/index.php --uri=worker/init_merchant_keywords
process_name = %(program_name)s_%(process_num)02d
numprocs = 2
autostart = true
autorestart = true
stdout_logfile = /var/log/gearman/init_merchant_keywords.log
stdout_logfile_maxbytes=1MB
stderr_logfile = /var/log/gearman/init_merchant_keywords_err.log
stderr_logfile_maxbytes=1MB
[program:gearman_daily_merchant_keywords]
command = php /var/code/xibao.com/index.php --uri=worker/daily_merchant_keywords
process_name = %(program_name)s_%(process_num)02d
numprocs = 4
autostart = true
autorestart = true
stdout_logfile = /var/log/gearman/daily_merchant_keywords.log
stdout_logfile_maxbytes=1MB
stderr_logfile = /var/log/gearman/daily_merchant_keywords_err.log
stderr_logfile_maxbytes=1MB
[program:gearman_aggregate_delegate_keywords]
command = php /var/code/xibao.com/index.php --uri=worker/aggregate_delegate_keywords
process_name = %(program_name)s_%(process_num)02d
numprocs = 4
autostart = true
autorestart = true
stdout_logfile = /var/log/gearman/aggregate_delegate_keywords.log
stdout_logfile_maxbytes=1MB
stderr_logfile = /var/log/gearman/aggregate_delegate_keywords_err.log
stderr_logfile_maxbytes=1MB
===================================================
supervisord -n
supervisord
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment