From: Radek Czajka Date: Thu, 27 Oct 2011 11:37:07 +0000 (+0200) Subject: celery supervisord conf X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/cc49ae50f55e14465c700350157478f79fd13d33?ds=inline;hp=402ff8830378ed95de69201b1f97718fad2eec5d celery supervisord conf --- diff --git a/.gitignore b/.gitignore index 944c338e2..c37544128 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dev.sqlite *.db-journal *~ *.orig +*.log # Compress output /wolnelektury/static/css/all.min*.css @@ -31,4 +32,4 @@ thumbs.db .tmp_* # Tags file -TAGS \ No newline at end of file +TAGS diff --git a/fabfile.py b/fabfile.py index 7e8934f63..21719872a 100644 --- a/fabfile.py +++ b/fabfile.py @@ -65,6 +65,7 @@ def deploy(): upload_tar_from_git() upload_wsgi_script() upload_vhost_sample() + upload_celery_conf() install_requirements() copy_localsettings() symlink_current_release() @@ -120,6 +121,12 @@ def upload_wsgi_script(): files.upload_template('%(project_name)s.wsgi.template' % env, '%(path)s/%(project_name)s.wsgi' % env, context=env) run('chmod ug+x %(path)s/%(project_name)s.wsgi' % env) +def upload_celery_conf(): + "Create and upload a Celery conf for supervisord" + print ">>> upload celery supervisord conf" + files.upload_template('%(project_name)s-celery.conf.template' % env, '%(path)s/%(project_name)s-celery.conf' % env, context=env) + run('chmod ug+x %(path)s/%(project_name)s-celery.conf' % env) + def install_requirements(): "Install the required packages from the requirements file using pip" print '>>> install requirements' @@ -157,3 +164,5 @@ def restart_webserver(): "Restart the web server" print '>>> restart webserver' run('touch %(path)s/%(project_name)s.wsgi' % env) + print '>>> restart Celery' + sudo('supervisord restart %(project_name)s-celery' % env) diff --git a/wolnelektury-celery.conf.template b/wolnelektury-celery.conf.template new file mode 100644 index 000000000..c5d24a4ca --- /dev/null +++ b/wolnelektury-celery.conf.template @@ -0,0 +1,24 @@ +; ========================================= +; WolneLektury-Celeryd conf for supervisord +; Put this in /etc/supervisor/conf.d +; ========================================= + +[program:%(project_name)s-celery] +command=%(path)s/bin/python %(path)s/releases/current/%(project_name)s/manage.py celeryd --loglevel=INFO +directory=%(path)s/releases/current/%(project_name)s +user=%(user)s +numprocs=2 +process_name=wolnelektury-celery-%%(process_num) +stdout_logfile=%(path)s/celeryd.log +stderr_logfile=%(path)s/celeryd.log +autostart=true +autorestart=true +startsecs=10 + +; Need to wait for currently executing tasks to finish at shutdown. +; Increase this if you have very long running tasks. +stopwaitsecs = 600 + +; if rabbitmq is supervised, set its priority higher +; so it starts first +priority=998 diff --git a/wolnelektury.wsgi.template b/wolnelektury.wsgi.template index 3437e8f3c..6a56ad7b6 100644 --- a/wolnelektury.wsgi.template +++ b/wolnelektury.wsgi.template @@ -1,6 +1,6 @@ #!%(python)s import site -site.addsitedir('%(path)s/lib/python2.5/site-packages') +site.addsitedir('%(path)s/lib/python2.6/site-packages') import os from os.path import abspath, dirname, join @@ -10,9 +10,6 @@ import sys # print statements for optional import exceptions. sys.stdout = sys.stderr -# we don't want these packages to cover our virtualenv -sys.path = [p for p in sys.path if not p.startswith('/usr/lib/python2.5/site-packages') and not p.startswith('/var/lib/python-support/python2.5')] - # Add apps and lib directories to PYTHONPATH sys.path = [ '%(path)s/releases/current/%(project_name)s', @@ -23,6 +20,7 @@ sys.path = [ ] + sys.path # Run Django +os.environ["CELERY_LOADER"] = "django" os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' from django.core.handlers.wsgi import WSGIHandler