From 7f35fd828a6cadc895c076cef9e75563e8ed2fde Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 8 Dec 2016 15:10:25 -0600 Subject: [PATCH] Add fab tasks: release, update_production --- fabfile.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 fabfile.py diff --git a/fabfile.py b/fabfile.py new file mode 100644 index 0000000..8113230 --- /dev/null +++ b/fabfile.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +""" +Fabric script for Rattail Demo +""" + +from __future__ import unicode_literals, absolute_import + +import shutil + +from fabric.api import * + +from rattail.fablib import cdvirtualenv, workon, python + + +env.roledefs = { + 'production': ['lance@rattailproject.org'], +} + + +@task +def release(): + """ + Release a new version of rattail-demo + """ + shutil.rmtree('rattail_demo.egg-info') + local('python setup.py sdist --formats=gztar upload') + + +@task +@roles('production') +def update_production(all='false'): + """ + Update production Rattail Demo server + """ + all = all.lower() == 'true' + if all: + with workon('demo'): + python.pip('pip', 'setuptools', 'wheel', 'ndg-httpsclient') + with cdvirtualenv('demo', 'src/rattail'): + sudo('git pull') + sudo('pip install --editable .') + with cdvirtualenv('demo', 'src/rattail-tempmon'): + sudo('git pull') + sudo('pip install --editable .') + with cdvirtualenv('demo', 'src/tailbone'): + sudo('git pull') + sudo('pip install --editable .') + + with cdvirtualenv('demo', 'src/rattail-demo'): + sudo('git pull') + if all: + sudo('pip install --upgrade --editable .') + else: + sudo('pip install --editable .') + with cd('/srv/envs/demo'): + sudo('bin/alembic --config=app/rattail.conf upgrade heads', user='rattail') + sudo('service apache2 restart')