FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
multi_function_github/deploy.sh at main · hourui9031/multi_function_github · GitHub
hourui9031
/
multi_function_github
Public
forked from
longbig/multi_function_github
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
multi_function_github
/
deploy.sh
Copy path
More file actions
More file actions
Latest commit
History
History
History
102 lines (92 loc) · 2.47 KB
Breadcrumbs
multi_function_github
/
deploy.sh
Copy path
File metadata and controls
102 lines (92 loc) · 2.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!
/bin/bash
#
修改APP_NAME为云效上的应用名
APP_NAME=application
PROG_NAME=
$0
ACTION=
$1
APP_START_TIMEOUT=20
#
等待应用启动的时间
APP_PORT=8080
#
应用端口
HEALTH_CHECK_URL=http://127.0.0.1:
${APP_PORT}
/checkHealth
#
应用健康检查URL
APP_HOME=/home/admin/
${APP_NAME}
#
从package.tgz中解压出来的jar包放到这个目录下
JAR_NAME=
${APP_HOME}
/target/
${APP_NAME}
.jar
#
jar包的名字
JAVA_OUT=
${APP_HOME}
/logs/start.log
#
应用的启动日志
#
创建出相关目录
mkdir -p
${APP_HOME}
mkdir -p
${APP_HOME}
/logs
usage
() {
echo
"
Usage:
$PROG_NAME
{start|stop|restart}
"
exit
2
}
health_check
() {
exptime=0
echo
"
checking
${HEALTH_CHECK_URL}
"
while
true
do
status_code=
`
/usr/bin/curl -L -o /dev/null --connect-timeout 5 -s -w %{http_code}
${HEALTH_CHECK_URL}
`
if
[
"
$?
"
!=
"
0
"
]
;
then
echo
-n -e
"
\rapplication not started
"
else
echo
"
code is
$status_code
"
if
[
"
$status_code
"
==
"
200
"
]
;
then
break
fi
fi
sleep 1
((
exptime
++
))
echo
-e
"
\rWait app to pass health check:
$exptime
...
"
if
[
$exptime
-gt
${APP_START_TIMEOUT}
]
;
then
echo
'
app start failed
'
exit
1
fi
done
echo
"
check
${HEALTH_CHECK_URL}
success
"
}
start_application
() {
echo
"
starting java process
"
nohup java -jar
${JAR_NAME}
>
${JAVA_OUT}
2>&1
&
echo
"
started java process
"
}
stop_application
() {
checkjavapid=
`
ps -ef
|
grep java
|
grep
${APP_NAME}
|
grep -v grep
|
grep -v
'
deploy.sh
'
|
awk
'
{print$2}
'
`
if
[[
!
$checkjavapid
]]
;
then
echo
-e
"
\rno java process
"
return
fi
echo
"
stop java process
"
times=60
for
e
in
$(
seq 60
)
do
sleep 1
COSTTIME=
$((
$times
-
$e
))
checkjavapid=
`
ps -ef
|
grep java
|
grep
${APP_NAME}
|
grep -v grep
|
grep -v
'
deploy.sh
'
|
awk
'
{print$2}
'
`
if
[[
$checkjavapid
]]
;
then
kill
-9
$checkjavapid
echo
-e
"
\r -- stopping java lasts
`
expr
$COSTTIME
`
seconds.
"
else
echo
-e
"
\rjava process has exited
"
break
;
fi
done
echo
"
"
}
start
() {
start_application
health_check
}
stop
() {
stop_application
}
case
"
$ACTION
"
in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*
)
usage
;;
esac
Back
|
FazBrowse Home
|
New Git URL