This repository has been archived by the owner on Jul 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
fabfile.py
110 lines (78 loc) · 2.62 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import os
from os.path import join as pjoin
import fabdeploytools.envs
from fabric.api import env, lcd, local, task, execute
from fabdeploytools import helpers
import deploysettings as settings
env.key_filename = settings.SSH_KEY
fabdeploytools.envs.loadenv(settings.CLUSTER)
SCL_NAME = getattr(settings, 'SCL_NAME', False)
if SCL_NAME:
helpers.scl_enable(SCL_NAME)
ROOT, APP = helpers.get_app_dirs(__file__)
VIRTUALENV = pjoin(ROOT, 'venv')
PYTHON = pjoin(VIRTUALENV, 'bin', 'python')
SRC = pjoin(APP, 'src')
USER_DATA = pjoin(settings.DATA_PATH, 'dumped-users', 'users')
APP_DATA = pjoin(settings.DATA_PATH, 'dumped-apps', 'apps')
os.environ['DJANGO_SETTINGS_MODULE'] = 'recommendation.settings.local'
def managecmd(cmd, run_dir=SRC):
with lcd(run_dir):
local('%s manage.py %s' % (PYTHON, cmd))
@task
def create_virtualenv(update_on_change=True):
helpers.create_venv(VIRTUALENV, settings.PYREPO,
pjoin(APP, 'requirements.prod.txt'),
update_on_change=update_on_change)
@task
def pre_update(ref):
with lcd(APP):
local('git fetch')
local('git fetch -t')
local('git reset --hard %s' % ref)
create_virtualenv()
@task
def syncdb(run_dir=SRC):
managecmd('syncdb', run_dir)
@task
def update():
syncdb()
@task
def deploy():
helpers.deploy(name=settings.PROJECT_NAME,
app_dir='frappe',
env=settings.ENV,
cluster=settings.CLUSTER,
domain=settings.DOMAIN,
package_dirs=['frappe', 'venv'],
root=ROOT)
helpers.restart_uwsgi(getattr(settings, 'UWSGI', []))
@task
def build():
execute(create_virtualenv)
@task
def deploy_jenkins():
rpm = helpers.build_rpm(name=settings.PROJECT_NAME,
app_dir='frappe',
env=settings.ENV,
cluster=settings.CLUSTER,
domain=settings.DOMAIN,
package_dirs=['frappe', 'venv'],
root=ROOT)
rpm.local_install()
execute(syncdb, os.path.join(rpm.install_to, 'frappe', 'src'))
rpm.remote_install(['web'])
helpers.restart_uwsgi(getattr(settings, 'UWSGI', []))
@task
def cron():
fill_data()
modelcrafter()
helpers.restart_uwsgi(getattr(settings, 'UWSGI', []))
@task
def fill_data():
managecmd('fill items --mozilla %s' % APP_DATA)
managecmd('fill users --mozilla %s' % USER_DATA)
@task
def modelcrafter():
managecmd('modelcrafter train tensorcofi')
managecmd('modelcrafter train popularity')