-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfabfile.py
72 lines (54 loc) · 1.91 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-03-14 15:58:57
# @Author : Linsir (root@linsir.org)
# @Link : http://linsir.org
# @Version :
import os
# from fabric.api import local,cd,run,env,put
from fabric.colors import *
from fabric.api import *
APP_NAME = 'lua-resty-ceph'
import paramiko
paramiko.util.log_to_file('/tmp/paramiko.log')
# 2. using sshd_config
env.hosts = [
'master',# master
]
env.use_ssh_config = True
prefix = '/usr/local/openresty/'
app_home = prefix + APP_NAME
def local_update():
print(yellow("Local: Copy %s and configure..." %APP_NAME))
if os.path.exists(app_home):
local("sudo rm -rf %s" %app_home)
local("sudo cp -r ../%s %s" %(APP_NAME, prefix))
if not os.path.exists("%snginx/conf/conf.d/%s" %(prefix, APP_NAME)):
local("sudo rm -rf %snginx/conf/conf.d/%s.conf" %(prefix, APP_NAME))
local("sudo ln -s %s/conf/nginx-example.conf %snginx/conf/conf.d/%s.conf" %(app_home, prefix, APP_NAME))
restart()
def remote_update():
print(yellow("Remote: Copy %s and configure..." %APP_NAME))
if os.path.exists(app_home):
run("sudo rm -rf %s" %app_home)
app = '../' + APP_NAME
put('app', prefix)
with cd('%snginx/conf/conf.d/'%prefix):
if not os.path.exists("%snginx/conf/conf.d/%s" %(prefix, APP_NAME)):
local("sudo rm -rf %snginx/conf/conf.d/%s.conf" %(prefix, APP_NAME))
local("sudo ln -s %s/conf/nginx-example.conf %snginx/conf/conf.d/%s.conf" %(app_home, prefix, APP_NAME))
print(green("openresty restarting..."))
run('/etc/init.d/nginx restart')
def restart():
print(green("nginx restarting..."))
local('sudo systemctl restart nginx')
local('curl http://127.0.0.1:8000/s3')
# local('curl http://127.0.0.1:8000/s3?cr=y&b=haha')
def update():
# local update
local_update()
# remote update
# remote_update()
pass
if __name__ == '__main__':
pass