-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfabfile.py
More file actions
46 lines (36 loc) · 1.65 KB
/
fabfile.py
File metadata and controls
46 lines (36 loc) · 1.65 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from fabric.api import run, env, cd, prefix, settings
# the user to use for the remote commands
env.user = 'answeror'
# the servers where the commands are executed
env.hosts = ['aip.io']
def runbg(cmd, sockname="dtach"):
return run('dtach -n `mktemp -u /tmp/%s.XXXX` %s' % (sockname, cmd))
def kill(name):
run("ps auxww | grep %s | grep -v \"grep\" | awk '{print $2}' | xargs kill -9 >& /dev/null" % name)
def gunicorn():
with settings(warn_only=True):
kill('gunicorn')
kill('celery')
kill('scrapyd')
# run('redis-cli flushall')
run('redis-cli keys "torabot:temp:*" | xargs redis-cli del')
run('redis-cli keys "torabot:spy:*" | xargs redis-cli del')
run('redis-cli keys "celery-task-meta-*" | xargs redis-cli del')
with cd('/www/torabot/repo'):
run('git pull')
with prefix('pyenv shell 2.7.6'):
with prefix('pyenv virtualenvwrapper'):
with prefix('workon www27'):
run('pip install -r dependencies-27.txt')
runbg('scrapyd')
run('./deployspy')
with prefix('pyenv shell 3.4.1'):
with prefix('pyenv virtualenvwrapper'):
with prefix('workon torabot34'):
run('pip install -r dependencies.txt')
run('python setup.py develop')
runbg('celery worker -A torabot -f data/celery-worker.log --autoscale=4,1')
runbg('celery beat -A torabot -f data/celery-beat.log')
runbg('gunicorn --pythonpath . -t 600 -w 2 -k gunicorn_worker.Worker gunicorn_app:app')