Add fab tasks: release, update_production

This commit is contained in:
Lance Edgar 2016-12-08 15:10:25 -06:00
parent 57dc4b917e
commit 7f35fd828a

57
fabfile.py vendored Normal file
View file

@ -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')