-
Notifications
You must be signed in to change notification settings - Fork 22
/
fabfile.py
67 lines (45 loc) · 1.3 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
import os
from fabric.api import *
base_path = os.path.dirname(__file__)
project_root = "~/Gather"
pip_path = os.path.join(project_root, "bin/pip")
python_path = os.path.join(project_root, "bin/python")
env.user = "gather"
env.hosts = ["gather.whouz.com"]
def update_from_github():
with cd(project_root):
run("git pull --rebase")
def update_pip_requirements():
with cd(project_root):
run("%s install -r requirements.txt" % pip_path)
def migrate_databases():
with cd(project_root):
run("%s manage.py db upgrade" % python_path)
run("%s manage.py create_all" % python_path)
def reload_nginx():
_current_user = env.user
env.user = 'root'
run("/etc/init.d/nginx reload")
env.user = _current_user
def restart_gunicorn():
_current_user = env.user
env.user = 'root'
run("supervisorctl reload")
env.user = _current_user
def reload_gunicorn():
run("kill -HUP `cat /tmp/gather.pid`")
def clear_cache():
with cd(project_root):
run("%s manage.py clear_cache" % python_path)
def update():
update_from_github()
migrate_databases()
reload_gunicorn()
clear_cache()
def fullyupdate():
update_from_github()
update_pip_requirements()
migrate_databases()
reload_nginx()
reload_gunicorn()
clear_cache()