This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfabfile.py
78 lines (54 loc) · 1.55 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
from fabric.api import cd, env, run
from fabric.operations import sudo
env.proj_root = '/var/webapps/betafarm/'
git_repo = 'https://github.com/mozilla/betafarm.git'
def run_manage_cmd(cmd):
"""Run a manage.py command."""
with cd(env.proj_root):
run('python manage.py %s' % (cmd,))
def restart_celeryd():
sudo('/etc/init.d/celeryd restart')
def restart_apache():
sudo('/etc/init.d/apache2 restart')
def clone():
"""Create project directory and clone repository."""
with cd(os.path.dirname(env.proj_root.rstrip('/'))):
run('git clone --recursive %s' % (git_repo,))
def update(branch):
"""Update project source."""
with cd(env.proj_root):
run('git pull origin %s' % (branch,))
def syncdb():
"""Run syncdb."""
run_manage_cmd('syncdb')
def migrate():
"""Run database migrations."""
run_manage_cmd('migrate')
def compress():
"""Compress CSS / Javascript."""
run_manage_cmd('compress_assets')
def new_branch(branch):
"""Checkout a new branch"""
with cd(env.proj_root):
run('git checkout -b %s origin/%s' % (branch, branch))
update(branch)
syncdb()
migrate()
compress()
restart_apache()
restart_celeryd()
def submodules():
with cd(env.proj_root):
run('git submodule init')
run('git submodule sync')
run('git submodule update')
def deploy(branch):
"""Deploy latest code from ``branch``."""
update(branch)
syncdb()
migrate()
compress()
submodules()
restart_apache()
restart_celeryd()