22 lines
617 B
Python
22 lines
617 B
Python
from fabric.api import *
|
|
|
|
env.user = 'ubuntu'
|
|
env.key_filename = '~/.ssh/ukad.pem'
|
|
|
|
env.hosts = (
|
|
'ec2-52-51-154-66.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 cd('/srv/api'):
|
|
run('tar xzf /tmp/api.tar.gz')
|
|
run('rm /tmp/api.tar.gz')
|
|
sudo('service nginx stop')
|
|
sudo('service api-uwsgi restart')
|
|
sudo('service nginx start')
|
|
local('rm /tmp/api.tar.gz')
|