-
Notifications
You must be signed in to change notification settings - Fork 2
/
fabfile.py
39 lines (29 loc) · 971 Bytes
/
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
34
35
36
37
38
39
from fabric.api import cd, env, prefix, run, sudo, task
from fabric.contrib.files import exists
env.user = "bdb-web"
env.hosts = ["cmbi23.cmbi.umcn.nl"]
def update_source():
"""Updates the source code on the host.
If the git repository already exists on the host, `git pull` is used;
otherwise, `git clone` is used.
"""
if exists("~/bdb-web"):
with cd("~/bdb-web"):
run("git pull")
else:
with cd("~"):
run("git clone https://github.com/cmbi/bdb-web.git")
def update_virtualenv():
"""Updates the virtualenv on the host."""
with cd("~/bdb-web"):
with prefix(". /usr/local/bin/virtualenvwrapper.sh; workon bdb-web"):
run("pip install -r requirements")
@task
def restart_gunicorn():
"""Restarts gunicorn on the host using supervisorctl."""
sudo("supervisorctl restart bdb-web")
@task
def deploy():
update_source()
update_virtualenv()
restart_gunicorn()