Files
api2/fabfile.py
T
2019-05-16 10:57:09 +02:00

25 lines
711 B
Python

from fabric.api import *
env.user = 'ubuntu'
env.key_filename = '~/.ssh/ukad.pem'
env.hosts = (
'ec2-52-50-174-196.eu-west-1.compute.amazonaws.com', #api2-dev
)
def deploy():
branch = local('git rev-parse --abbrev-ref HEAD', capture=True)
local('git archive --format tar.gz -o /tmp/api.tar.gz {0}'.format(branch), capture=False)
put('/tmp/api.tar.gz', '/tmp/api.tar.gz')
with warn_only():
sudo('service nginx stop')
sudo('service api-uwsgi stop')
with cd('/srv/api'):
run('tar xzf /tmp/api.tar.gz')
run('rm /tmp/api.tar.gz')
with warn_only():
sudo('service api-uwsgi start')
sudo('service nginx start')
local('rm /tmp/api.tar.gz')