-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfabfile.py
More file actions
78 lines (58 loc) · 2.2 KB
/
Copy pathfabfile.py
File metadata and controls
78 lines (58 loc) · 2.2 KB
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
from fabric.api import run, env, local, cd, prefix, sudo
# Create an ssh config in ~/.ssh/config
# Host phase
# HostName phase.testing.com
# User phase
#
# Also add this line in /etc/sudoers on the server if you want
# the phase user to be able to restart supervisor:
# phase ALL = (root) NOPASSWD:/usr/bin/supervisorctl restart phase
# phase ALL = (root) NOPASSWD:/usr/bin/supervisorctl restart celery
USERNAME = 'phase'
VENV_HOME = '/home/%s/.virtualenvs/' % USERNAME
env.use_ssh_config = True
env.hosts = ['phase']
env.activate = 'workon phase'
env.directory = '/home/%s/phase' % USERNAME
env.sudo_prefix = 'sudo '
def runserver():
"""Runs the local Django server."""
runserver = 'python src/manage.py runserver'
with_local_settings = ' --settings=core.settings.local'
local(runserver + with_local_settings)
def test(module=""):
"""Launches tests for the whole project."""
runtests = 'coverage run src/manage.py test {module}'.format(
module=module
)
with_test_settings = ' --settings=core.settings.test'
local(runtests + with_test_settings)
def docs():
"""Generates sphinx documentation for the project."""
local('cd docs && make clean && make html')
local('xdg-open docs/_build/html/index.html')
def check():
"""Checks that everything is fine, useful before deploying."""
test()
docs()
runserver()
def restart_webserver():
sudo('supervisorctl restart phase', shell=False)
sudo('supervisorctl restart celery', shell=False)
def reindex_all():
with cd(env.directory):
with prefix(env.activate):
reindex = 'python src/manage.py reindex_all --noinput'
with_production_settings = ' --settings=core.settings.production'
run(reindex + with_production_settings)
def log(filename="admin/log/access.log", backlog='F'):
"""Displays access.log file from staging."""
run("tail -%s '%s'" % (backlog, filename))
def errors(backlog=200):
"""Displays error.log file from staging."""
return log("admin/log/error.log", backlog)
def bootstrap():
sudo('service postgresql start')
sudo('service rabbitmq-server start')
sudo('service memcached start')
sudo('service elasticsearch start')