-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
76 lines (58 loc) · 1.67 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
#!/usr/bin/env python
# encoding: utf-8
# @author: ZhouYang
import fabric
host = 'zhouyang@teldrassil.zhouyang.me'
path = '/usr/webapps/python/sportsapp'
@fabric.api.hosts(host)
def reload(path=path):
""" Restarting sportsapp
"""
with fabric.api.cd(path):
print fabric.colors.green("stoping server")
fabric.api.sudo('sh shutdown.sh')
print fabric.colors.green("starting server")
fabric.api.sudo('sh startup.sh')
print fabric.colors.green("starting finished")
@fabric.api.hosts(host)
def stop(path=path):
""" Stopping sportsapp
"""
with fabric.api.cd(path):
fabric.api.sudo('sh shutdown.sh')
@fabric.api.hosts(host)
def start(path=path):
""" Starting sportsapp
"""
with fabric.api.cd(path):
fabric.api.sudo('sh startup.sh')
@fabric.api.hosts(host)
def update(path=path, sqls=None):
""" Update sportsapp from github
"""
with fabric.api.cd(path):
fabric.api.sudo('git pull')
if sqls:
print fabric.colors.green("start execute sql files")
sqls_list = sqls.split(',')
for sql in sqls_list:
print fabric.colors.green("executing %s" % sql)
fabric.api.run(
"mysql -usportsapp -psportsapp sportsapp < " + path + "/sportsapp/sql/" + sql)
else:
print fabric.colors.yellow("sqls is None, task over")
@fabric.api.hosts(host)
def nginx_reload():
""" Reload nginx
"""
fabric.api.sudo('nginx -s reload')
@fabric.api.hosts(host)
def nginx_stop():
""" Stop nginx
"""
fabric.api.sudo('nginx -s stop')
@fabric.api.hosts(host)
def nginx_start():
""" Stop start
"""
fabric.api.sudo('nginx')