forked from sinnwerkstatt/landmatrix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
91 lines (75 loc) · 2.91 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
79
80
81
82
83
84
85
86
87
88
89
90
91
from datetime import datetime
from fabric.api import cd, run, env, local, hide, settings
from fabric.contrib import django
from fabric.operations import get
from fabvenv import virtualenv
def dev():
env.name = 'staging'
env.hosts = ['[email protected]']
env.path = '/home/landmatrix/landmatrix-dev'
env.virtualenv_path = '/home/landmatrix/.virtualenvs/landmatrix-dev'
env.push_branch = 'master'
env.push_remote = 'origin'
env.reload_cmd = 'sudo supervisorctl restart landmatrix-dev'
env.db_name = 'landmatrix'
env.db_username = 'landmatrix'
env.after_deploy_url = 'http://beta.landmatrix.org'
def production():
env.name = 'production'
env.hosts = ['[email protected]']
env.path = '/home/landmatrix/landmatrix'
env.virtualenv_path = '/home/landmatrix/.virtualenvs/landmatrix'
env.backup_path = '/srv/lmlo.sinnwerkstatt.com/backups'
env.push_branch = 'master'
env.push_remote = 'origin'
env.reload_cmd = 'supervisorctl restart landmatrix'
env.db_name = 'landmatrix'
env.db_username = 'landmatrix'
def compile_less():
pass
def reload_webserver():
run("%(reload_cmd)s" % env)
def migrate():
with virtualenv(env.virtualenv_path):
run("%(path)s/manage.py syncdb" % env)
run("%(path)s/manage.py migrate" % env)
def ping():
run("echo %(after_deploy_url)s returned: \>\>\> $(curl --write-out %%{http_code} --silent --output /dev/null %(after_deploy_url)s)" % env)
def deploy():
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
compile_less()
with virtualenv(env.virtualenv_path):
run("pip install -Ur requirements.txt")
run("./manage.py collectstatic --noinput")
migrate()
reload_webserver()
ping()
def hotdeploy():
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
compile_less()
with virtualenv(env.virtualenv_path):
run("./manage.py collectstatic --noinput")
reload_webserver()
def init_fixtures():
with virtualenv(env.virtualenv_path):
run("%(path)s/manage.py loaddata init.json" % env)
def update():
''' Only deploy and reload modules from git, do no installing or migrating'''
with cd(env.path):
run("git pull %(push_remote)s %(push_branch)s" % env)
compile_less()
with virtualenv(env.virtualenv_path):
run("./manage.py collectstatic --noinput")
reload_webserver()
def backup():
with cd(env.backup_path):
run("pg_dump -U %(db_username)s %(db_name)s > %(db_name)s_backup_$(date +%%F-%%T).sql" % env)
run("ls -lt")
def rebuild_index():
with virtualenv(env.virtualenv_path):
run("%(path)s/manage.py rebuild_index -v 2" % env)
def update_index():
with virtualenv(env.virtualenv_path):
run("%(path)s/manage.py update_index -v 2" % env)