|
|
@@ -19,24 +19,22 @@ def call(Map args = [:]) {
|
|
|
try {
|
|
|
/* 1. 按端口杀旧进程,并确认端口已释放 */
|
|
|
sh """
|
|
|
- ssh -o StrictHostKeyChecking=no ${remoteHost} '
|
|
|
- set -e
|
|
|
- OLD_PID=\\$(lsof -ti:${remotePort} || true)
|
|
|
- if [ -n "\\$OLD_PID" ]; then
|
|
|
- echo "杀掉占用端口 ${remotePort} 的进程 \\$OLD_PID"
|
|
|
- kill -9 \\$OLD_PID
|
|
|
- sleep 3
|
|
|
- fi
|
|
|
- if lsof -ti:${remotePort}; then
|
|
|
- echo "端口 ${remotePort} 仍未释放,杀进程失败"
|
|
|
- exit 1
|
|
|
- fi
|
|
|
- '
|
|
|
+ ssh -o StrictHostKeyChecking=no ${remoteHost} \\
|
|
|
+ 'OLD_PID=\\$(lsof -ti:${remotePort} || true)
|
|
|
+ if [ -n "\\$OLD_PID" ]; then
|
|
|
+ echo \"杀掉占用端口 ${remotePort} 的进程 \\$OLD_PID\"
|
|
|
+ kill -9 \\$OLD_PID
|
|
|
+ sleep 3
|
|
|
+ fi
|
|
|
+ if lsof -ti:${remotePort}; then
|
|
|
+ echo \"端口 ${remotePort} 仍未释放,杀进程失败\"
|
|
|
+ exit 1
|
|
|
+ fi'
|
|
|
"""
|
|
|
|
|
|
/* 2. 备份旧包 */
|
|
|
sh """
|
|
|
- ssh -o StrictHostKeyChecking=no ${remoteHost} \
|
|
|
+ ssh -o StrictHostKeyChecking=no ${remoteHost} \\
|
|
|
'test -f ${remoteJar} && mv ${remoteJar} ${remoteJar}-\\$(date +%Y%m%d%H%M) || true'
|
|
|
"""
|
|
|
|
|
|
@@ -50,12 +48,10 @@ def call(Map args = [:]) {
|
|
|
|
|
|
/* 4. 启动新进程 */
|
|
|
sh """
|
|
|
- ssh -o StrictHostKeyChecking=no ${remoteHost} '
|
|
|
- set -e
|
|
|
- cd ${remotePath}
|
|
|
- nohup java ${jvmArgs} -jar ${jarName} --spring.profiles.active=${profile} > server.log 2>&1 &
|
|
|
- sleep 5
|
|
|
- '
|
|
|
+ ssh -o StrictHostKeyChecking=no ${remoteHost} \\
|
|
|
+ 'cd ${remotePath} &&
|
|
|
+ nohup java ${jvmArgs} -jar ${jarName} --spring.profiles.active=${profile} > server.log 2>&1 &
|
|
|
+ sleep 5'
|
|
|
"""
|
|
|
|
|
|
/* 5. 按 profile 精确校验:有且仅有 1 个进程 */
|