Skip to content
This repository has been archived by the owner on Jan 25, 2018. It is now read-only.

Commit

Permalink
Add Scl support to fabfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
oremj committed Dec 16, 2013
1 parent 1345aa9 commit ea6b634
Showing 1 changed file with 7 additions and 29 deletions.
36 changes: 7 additions & 29 deletions fabfile.py
Expand Up @@ -2,7 +2,6 @@
from fabric.api import (env, execute, lcd, local, parallel,
run, roles, task)

from fabdeploytools.rpm import RPMBuild
from fabdeploytools import helpers
import fabdeploytools.envs

Expand All @@ -12,6 +11,10 @@
env.key_filename = settings.SSH_KEY
fabdeploytools.envs.loadenv(settings.CLUSTER)

SCL_NAME = getattr(settings, 'SCL_NAME', False)
if SCL_NAME:
helpers.scl_enable(SCL_NAME)

ROOT, WEBPAY = helpers.get_app_dirs(__file__)

VIRTUALENV = os.path.join(ROOT, 'venv')
Expand All @@ -25,18 +28,9 @@ def managecmd(cmd):

@task
def create_virtualenv():
with lcd(WEBPAY):
# Compare the last reflog change with the latest change we introduced.
status = local('git diff HEAD@{1} HEAD --name-only', capture=True)

if 'requirements/' in status:
venv = VIRTUALENV
if not venv.startswith('/data'):
raise Exception('venv must start with /data')

local('rm -rf %s' % venv)
helpers.create_venv(venv, settings.PYREPO,
'%s/requirements/prod.txt' % WEBPAY)
helpers.create_venv(VIRTUALENV, settings.PYREPO,
'%s/requirements/prod.txt' % WEBPAY,
update_on_change=True, rm_first=True)


@task
Expand Down Expand Up @@ -67,21 +61,6 @@ def update_info(ref='origin/master'):
'> media/git-rev.txt'.format(ref))


@task
@roles('web')
@parallel
def restart_workers():
for gservice in settings.GUNICORN:
run("/sbin/service %s graceful" % gservice)
restarts = []
for g in settings.MULTI_GUNICORN:
restarts.append('( supervisorctl restart {0}-a; '
'supervisorctl restart {0}-b )&'.format(g))

if restarts:
run('%s wait' % ' '.join(restarts))


@task
@roles('celery')
@parallel
Expand All @@ -101,7 +80,6 @@ def deploy():
deploy_roles=['web', 'celery'],
package_dirs=['webpay', 'venv'])

execute(restart_workers)
helpers.restart_uwsgi(getattr(settings, 'UWSGI', []))
execute(update_celery)

Expand Down

0 comments on commit ea6b634

Please sign in to comment.