/
fabfile.py
46 lines (35 loc) · 1.05 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
from fabric.api import *
from fabric.contrib.console import confirm
import os
REMOTE_PROJECT_DIR = '/home/web/can_o_beans/'
REMOTE_ACTIVATE_VENV = 'workon cob'
def pull():
with cd(REMOTE_PROJECT_DIR):
run('git pull')
def collect_static():
with cd(REMOTE_PROJECT_DIR):
with prefix(REMOTE_ACTIVATE_VENV):
run('./manage.py collectstatic --noinput')
def migrate_app(app_name):
with cd(REMOTE_PROJECT_DIR):
with prefix(REMOTE_ACTIVATE_VENV):
run('./manage.py migrate {0}'.format(app_name))
def stop_uwsgi():
run('su -c "supervisorctl stop uwsgi"')
def start_uwsgi():
run('su -c "supervisorctl start uwsgi"')
def restart_uwsgi():
run('su -c "supervisorctl restart uwsgi"')
def stop_nginx():
run('su -c "invoke-rc.d nginx stop"')
def start_nginx():
run('su -c "invoke-rc.d nginx start"')
def clear_cache():
run('nc "flushall\n" localhost 11211')
def deploy():
pull()
collect_static()
migrate_app('journal')
migrate_app('bookmarks')
restart_uwsgi()
clear_cache()