forked from mozilla/betafarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
63 lines (43 loc) · 1.22 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
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_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():
"""Update project source."""
with cd(env.proj_root):
run('git pull origin master')
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 switch(branchname):
"""Switch branches"""
with cd(env.proj_root):
run('git checkout %s' % (branchname,))
run('git pull origin %s' % (branchname,))
syncdb()
migrate()
compress()
restart_apache()
def deploy():
update()
syncdb()
migrate()
compress()
restart_apache()