supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[program:gunicorn]
-environment = DJANGO_SETTINGS_MODULE=karmaworld.settings.prod
-command = gunicorn -c confs/production/gunicorn.conf karmaworld.wsgi:application
+command = ./manage.py run_gunicorn -c confs/production/gunicorn.conf
autostart = true
autorestart = true
redirect_stderr = true
stopsignal = QUIT
[program:celeryd]
-environment = DJANGO_SETTINGS_MODULE=karmaworld.settings.prod
-command = ./manage.py celery worker --app=karmaworld.celery.config --pidfile=var/run/celeryd.pid -l info
+command = ./manage.py celery worker --pidfile=var/run/celeryd.pid -l info
autorestart = true
redirect_stderr = true
stdout_logfile = var/log/celeryd.log
-priority = 2
[program:celerybeat]
environment = DJANGO_SETTINGS_MODULE=karmaworld.settings.prod
-command = ./manage.py celery beat --app=karmaworld.celery.config --pidfile=var/run/celerybeat.pid -s var/run/celerybeat-schedule -l info
+command = ./manage.py celery beat --pidfile=var/run/celerybeat.pid -s var/run/celerybeat-schedule -l info
autorestart = true
redirect_stderr = true
stdout_logfile = var/log/celerybeat.log
env.branch = 'beta'
env.run = virtenv_exec
+
+
####### Define production host
@task
def prod():
"""
env.user = 'djkarma'
- env.hosts = ['beta.karmanotes.org']
+ env.hosts = ['karmanotes.org']
env.proj_root = '/var/www/karmaworld'
env.proj_dir = '/var/www/karmaworld'
env.reqs = 'reqs/prod.txt'
env.run = virtenv_exec
env.gunicorn_addr = '127.0.0.1:8000'
+####### Define beta host
+@task
+def beta():
+ """
+ Connection Information for beta machine
+ """
+
+ env.user = 'djkarma'
+ env.hosts = ['beta.karmanotes.org']
+ env.proj_root = '/var/www/karmaworld'
+ env.proj_dir = '/var/www/karmaworld'
+ env.reqs = 'reqs/beta.txt'
+ env.confs = 'confs/beta/'
+ env.branch = 'beta'
+ env.run = virtenv_exec
+ env.gunicorn_addr = '127.0.0.1:8000'
+
######## Run Commands in Virutal Environment
def virtenv_exec(command):
"""
"""
run('virtualenv %s/%s' % (env.proj_root, env.branch))
- env.run('pip install -r %s/reqs/dev.txt' % env.proj_dir )
+ env.run('pip install -r %s/reqs/%s.txt' % (env.proj_dir, env.branch) )
+
+@task
+def start_supervisord():
+ """
+ Starts supervisord
+ """
+ config_file = '/var/www/karmaworld/confs/prod/supervisord.conf'
+ env.run('supervisord -c %s' % config_file)
+
+
+@task
+def stop_supervisord():
+ """
+ Restarts supervisord
+ """
+ config_file = '/var/www/karmaworld/confs/prod/supervisord.conf'
+ env.run('supervisorctl -c %s shutdown' % config_file)
+
+
+@task
+def restart_supervisord():
+ """
+ Restarts supervisord
+ """
+ stop_supervisord()
+ start_supervisord()
+
+
+def supervisorctl(action, process):
+ """
+ Takes as arguments the name of the process as is
+ defined in supervisord.conf and the action that should
+ be performed on it: start|stop|restart.
+ """
+ supervisor_conf = '/var/www/karmaworld/confs/prod/supervisord.conf'
+ env.run('supervisorctl -c %s %s %s' % (supervisor_conf, action, process))
+
+
+@task
+def start_celeryd():
+ """
+ Starts the celeryd process
+ """
+ supervisorctl('start', 'celeryd')
+
+
+@task
+def stop_celeryd():
+ """
+ Stops the celeryd process
+ """
+ supervisorctl('stop', 'celeryd')
+
+
+@task
+def restart_celery():
+ """
+ Restarts the celeryd process
+ """
+ supervisorctl('restart', 'celeryd')
+
-####### Start Gunicorn
@task
def start_gunicorn():
"""
Starts the gunicorn process
"""
- env.run('%s/manage.py run_gunicorn -b %s -p %s/var/run/gunicorn.pid --daemon' % (env.proj_dir, env.gunicorn_addr, env.proj_dir))
+ supervisorctl('start', 'gunicorn')
+
+
+@task
+def stop_gunicorn():
+ """
+ Stops the gunicorn process
+ """
+ supervisorctl('stop', 'gunicorn')
+
+
+@task
+def restart_gunicorn():
+ """
+ Restarts the gunicorn process
+ """
+ supervisorctl('restart', 'gunicorn')
+
####### Update Requirements
@task