forked from hustlzp/blogbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfabfile.py
More file actions
51 lines (40 loc) · 1.39 KB
/
fabfile.py
File metadata and controls
51 lines (40 loc) · 1.39 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
47
48
49
50
51
# coding: utf-8
from fabric.api import run, env, cd, prefix, shell_env
from config import load_config
config = load_config()
host_string = config.HOST_STRING
def deploy():
"""部署"""
env.host_string = config.HOST_STRING
with cd('/var/www/blogbar'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
run('bower install --allow-root')
with prefix('source venv/bin/activate'):
run('pip install -r requirements.txt')
run('python manage.py db upgrade')
run('supervisorctl restart blogbar')
def pull():
"""更新代码"""
env.host_string = config.HOST_STRING
with cd('/var/www/blogbar'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
def restart():
"""重启"""
env.host_string = config.HOST_STRING
run('supervisorctl restart blogbar')
def restart_celery():
"""重启celery相关进程"""
env.host_string = config.HOST_STRING
run('supervisorctl restart celery')
run('supervisorctl restart celerybeat')
run('supervisorctl restart celeryflower')
def remote_grab():
"""启动feed抓取"""
env.host_string = config.HOST_STRING
with cd('/var/www/blogbar'):
with prefix('source venv/bin/activate'):
run('python manage.py remote_grab')