/
fabfile.py
47 lines (40 loc) · 1.48 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
from fabric.api import run, env, cd, prefix, shell_env, local
from local_config import HOST_STRING
def deploy():
env.host_string = HOST_STRING
with cd('/home/flask/source/codingpy'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
with prefix('source /home/flask/flaskenv/bin/activate'):
run('pip install -r requirements.txt')
run('python manage.py db upgrade')
run('python manage.py build')
run('supervisorctl restart codingpy')
def restart():
env.host_string = HOST_STRING
with cd('/home/flask/source/codingpy'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
run('supervisorctl restart codingpy')
def stop():
env.host_string = HOST_STRING
with cd('/home/flask/source/codingpy'):
run('service nginx stop')
run('supervisorctl stop codingpy')
def pull():
env.host_string = HOST_STRING
with cd('/home/flask/source/codingpy'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
def start():
env.host_string = HOST_STRING
with cd('/home/flask/source/codingpy'):
with shell_env(MODE='PRODUCTION'):
run('git reset --hard HEAD')
run('git pull')
run('service nginx restart')
run('supervisorctl start codingpy')