-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
63 lines (45 loc) · 1.44 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import sys
from fabric.api import env, run, cd
"""
Sample fabric file. Assumes the following on production server:
- virtualenv + virtualenvwrapper
- mercurial
- supervisord (running gunicorn/uwsgi etc.)
Copy and modify as required for your own particular setup.
Keep your private settings in a separate module, fab_settings.py, in
the same directory as this file.
"""
try:
import fab_settings as settings
except ImportError:
print "You must provide a valid fab_settings.py module in this directory"
sys.exit(1)
def server():
env.hosts = settings.SERVER_HOSTS
env.user = settings.SERVER_USER
env.password = settings.SERVER_PASSWORD
def deploy():
"""
Pulls latest code into staging, runs tests, then pulls into live.
"""
providers = (server,)
with cd(settings.STAGING_DIR):
run("hg pull -u")
run("workon %s;nosetests" % settings.VIRTUALENV)
with cd(settings.PRODUCTION_DIR):
run("hg pull -u")
def reload():
"""
Deploys and then reloads application server.
"""
deploy()
run("supervisorctl -c %s restart %s" % (settings.SUPERVISOR_CONF,
settings.SUPERVISOR_CMD))
def upgrade():
"""
Updates all required packages, runs tests, then updates packages on
live, then restarts server.
"""
with cd(settings.PRODUCTION_DIR):
run("workon %s; python setup.py develop -U" % settings.VIRTUALENV)
reload()