-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabfile.py
47 lines (32 loc) · 1.08 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
# coding: utf-8
import os
from fabric.api import run, env, cd, roles, sudo
from fabric.contrib.project import rsync_project
env.hosts = ['[email protected]']
project_name = 'qvpa_system'
project_root = 'qvpa'
project_path = '/webapps/{0}/{1}'.format(project_root, project_name)
project_sync_dir = '/webapps/{0}/'.format(project_root)
venv_path = '/webapps/{0}/env_qvpa/bin'.format(project_root)
python = '{0}/python'.format(venv_path)
pip = '{0}/pip'.format(venv_path)
rsync_excludes = ['*.pyc', '*.db', '*~']
def sync():
rsync_project(project_sync_dir, delete=False, exclude=rsync_excludes)
def install_requirements():
run('{0} install -r {1}/requirements.txt'.format(pip, project_path))
def db_migrate():
run('{0} {1}/manage.py migrate --noinput'.format(python, project_path))
def collectstatic():
run('{0} {1}/manage.py collectstatic --no-input'.format(
python,
project_path
))
def restart():
sudo('supervisorctl restart {}'.format(project_root))
def deploy():
sync()
install_requirements()
db_migrate()
collectstatic()
restart()