-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfabfile.py
33 lines (27 loc) · 1.11 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from fabric.api import env, task, run, local, prefix
from fabric.operations import prompt
env.hosts = ["elcid-uch-test.openhealthcare.org.uk"]
env.user = "ubuntu"
virtual_env_name = "gloss"
@task
def deploy_test(key_file_name="../ec2.pem"):
env.key_filename = key_file_name
changes = local("git status --porcelain", capture=True)
if len(changes):
print " {}".format(changes)
proceed = prompt(
"you have uncommited changes, do you want to proceed",
default=False,
validate=bool
)
if not proceed:
return
git_branch_name = local('git rev-parse --abbrev-ref HEAD', capture=True)
with prefix(". /usr/share/virtualenvwrapper/virtualenvwrapper.sh"):
with prefix("workon {}".format(virtual_env_name)):
run("git pull origin {}".format(git_branch_name))
run("pip install -r requirements.txt")
run("alembic upgrade head")
with prefix("workon elcid"):
run("supervisorctl -c etc/test.conf restart gloss")
run("supervisorctl -c etc/test.conf restart gloss_flask")