Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
antai-sport-http-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
antai-sport
antai-sport-http-server
Commits
bcd1d552
Commit
bcd1d552
authored
Apr 25, 2022
by
liming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加流水线部署脚本
parent
3c18c5e5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
deploy-management-api.sh
deploy/deploy-management-api.sh
+97
-0
No files found.
deploy/deploy-management-api.sh
0 → 100644
View file @
bcd1d552
#!/bin/bash
# 修改APP_NAME为云效上的应用名
APP_NAME
=
antai-sport-http-server-management-api
PROG_NAME
=
$0
ACTION
=
$1
BASE_HOME
=
/usr/local/project/management-api/management-api/target
APP_START_TIMEOUT
=
30
# 等待应用启动的时间
APP_PORT
=
8089
# 应用端口
HEALTH_CHECK_URL
=
http://127.0.0.1:
${
APP_PORT
}
# 应用健康检查URL
JAR_NAME
=
${
BASE_HOME
}
/
${
APP_NAME
}
.jar
# jar包的名字
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
"
\r
application not started"
else
echo
"code is
$status_code
"
if
[
"
$status_code
"
==
"200"
]
;
then
break
fi
fi
sleep
1
((
exptime++
))
echo
-e
"
\r
Wait 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
}
--spring
.profiles.active
=
prod
--server
.port
=
${
APP_PORT
}
>
/dev/null 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
"
\r
no 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
"
\r
java 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
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment