forked from hamidfzm/Rest-in-Flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
78 lines (53 loc) · 1.37 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
from fabric.api import *
from fabvenv import virtualenv
from os import path
env.hosts = ['me@example.com']
home = '/var/www/example/'
project = path.join(home, 'backend/')
venv = path.join(home, 'env')
logl = path.join(home, 'log/')
def pull(*args):
with cd(project):
run('git pull -u origin master')
run('chown www-data:www-data -R *')
def reset():
run('touch %s' % path.join(home, 'reload'))
run('service nginx reload')
def pull_in_server():
pull()
jsons()
reset()
doc()
def clean():
with cd(project):
run('find . -name "*.pyc" -exec rm -rf {} \;')
run('rm -rf /tmp/cache/')
def sync():
local("git pull origin master")
local("git push origin master")
def serlog():
run('tail -n 100 %s' % path.join(logl, 'uwsgi.log'))
def doc():
with cd(project):
with virtualenv(venv):
run('./manager.py doc')
def jsons():
with cd(project):
with virtualenv(venv):
run('./manager.py jsons')
def deploy():
sync()
pull_in_server()
serlog()
def requirements():
sync()
pull()
with cd(project):
with virtualenv(venv):
run('pip install -r requirements')
reset()
serlog()
def errors():
run('tail -n 100 %s' % path.join(logl, 'nginx-error.log'))
def log():
run('tail -n 100 %s' % path.join(logl, 'nginx-access.log'))