-
Notifications
You must be signed in to change notification settings - Fork 715
/
fabfile.py
57 lines (42 loc) · 1.27 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
import os,logging
from fabric.api import task,local,run,put,get,lcd,cd,sudo
import django,sys
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='logs/fab.log',
filemode='a')
@task
def shell():
local('python manage.py shell')
@task
def local_static():
local('python manage.py collectstatic')
@task
def migrate():
local('python manage.py makemigrations')
local('python manage.py migrate')
@task
def worker(queue_name,conc=1):
conc = int(conc)
command = 'celery -A dca worker -l info -c {} -Q {} -n {}.%h -f logs/celery.log'.format(conc,queue_name,queue_name)
if sys.platform != 'darwin':
command = "source ~/.profile && "+command
local(command=command)
@task
def server():
local("python manage.py runserver")
@task
def start_server_container():
local('sleep 60')
migrate()
local('python start_extractor.py &')
local('python start_indexer.py &')
local('python manage.py runserver 0.0.0.0:8000')
@task
def clean():
local('python manage.py flush')
migrate()
local("rm logs/*.log")
local("rm -rf ~/media/*")
local("mkdir ~/media/queries")