-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.sh
84 lines (71 loc) · 1.87 KB
/
debug.sh
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
79
80
81
82
83
84
###
# @Author: cA7dEm0n
# @Blog: http://www.a-cat.cn
# @Since: 2020-12-30 17:14:05
# @Motto: 欲目千里,更上一层
# @message: 本地DEBUG测试
###
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
POD_NAME="gateway"
IMAGE_NAME="code/gateway"
run() {
docker ps |grep -q ${POD_NAME} && exit 0
docker run -d -p 8888:8888 \
-v ${SCRIPT_DIR}/conf:/usr/local/openresty/nginx/conf \
-v ${SCRIPT_DIR}/deps:/usr/local/openresty/nginx/deps/ \
-v ${SCRIPT_DIR}/gateway:/usr/local/openresty/nginx/gateway/ \
-v ${SCRIPT_DIR}/init:/usr/local/openresty/nginx/init/ \
-v ${SCRIPT_DIR}/rockspec:/usr/local/openresty/nginx/rockspec/ \
--name ${POD_NAME} ${IMAGE_NAME}
}
log() {
docker logs -f ${POD_NAME}
}
stop() {
docker stop ${POD_NAME}
}
start() {
docker start ${POD_NAME}
}
rm_() {
docker rm ${POD_NAME}
}
reload() {
docker exec ${POD_NAME} /usr/local/openresty/bin/openresty -s reload
}
init_services() {
local token=$1
curl http://127.0.0.1:8888/api/mg/admin/services/save -H "X-Api-Token: ${token}" -X POST -d'
{
"service_name": "demo1",
"upstream": "127.0.0.1:1024",
"weight": 1,
"status": 1
}'
}
init_routes() {
local token=$1
curl http://127.0.0.1:8888/api/mg/admin/routes/save -H "X-Api-Token: ${token}" -X POST -d '
{
"prefix": "/openapi/demo1/*",
"status": 1,
"service_name": "demo1",
"protocol": "http",
"plugins": ["discovery", "tracing", "rewrite", "redis-logger"],
"props": {
"rewrite_url_regex": "^/openapi/(.*)/",
"rewrite_replace": "/openapi/"
}
}'
}
init() {
token=e09d6153f1c15395397be3639d144794
# curl http://127.0.0.1:8888/api/mg/admin/plugins/list -H "X-Api-Token: e09d6153f1c15395397be3639d144794"
init_services ${token}
init_routes ${token}
}
restart() {
stop
start
}
$*