From 3527b2776a0487d79fc03ed4a4a013a286e269b4 Mon Sep 17 00:00:00 2001 From: YangHongxiao <76406840@qq.com> Date: Mon, 24 Oct 2022 19:23:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[:rocket:]=E8=87=AA=E5=8A=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=88=B0Shell=E8=84=9A=E6=9C=AC=E6=89=80=E5=9C=A8?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/script/app.sh | 144 +++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 83 deletions(-) diff --git a/docs/script/app.sh b/docs/script/app.sh index 5514ef0..7e5a3b0 100644 --- a/docs/script/app.sh +++ b/docs/script/app.sh @@ -1,135 +1,113 @@ #!/bin/sh -#功能简介:启动 xxx.jar 文件 -#请先cd到项目下执行 -#注意:在sh文件中=赋值,左右两侧不能有空格 +# 功能简介:启动 xxx.jar 文件 +# 请先cd到项目下执行 +# 注意:在sh文件中=赋值,左右两侧不能有空格 # .Power by terrfly -#当前所在目录 -PROJECT_PATH=$(cd `dirname $0`; pwd) +# 获取当前Shell脚本所在目录,并切换到该目录 +PROJECT_PATH=$(cd $(dirname $0); pwd) +cd "${PROJECT_PATH}" -#当前所在文件夹名 +# 当前所在文件夹名 PROJECT_NAME="${PROJECT_PATH##*/}" - -#jar名称 +# jar名称 APP_NAME='jeepay-'$PROJECT_NAME'.jar' -#======================================================================= - -#当前应用进行的变量标识 +# ======================================================================= +# 当前应用进程的变量标识 APP_PID='' - # 重新获取APPID -function refAppPID(){ - - APP_PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v kill|awk '{print $2}'` +function refAppPID() { + APP_PID=$(ps -ef | grep $APP_NAME | grep -v grep | grep -v kill | awk '{print $2}') } - # 获取运行程序的pid 进程号 -function getAppPID(){ - - if [ ! $APP_PID ]; then #未获取过 - refAppPID - fi +function getAppPID() { + if [ ! $APP_PID ]; then # 未获取过 + refAppPID + fi } - # 启动 -function start(){ +function start() { + refAppPID # 获取进程PID, 需重新获取,避免restart时无法正确启动。 - refAppPID #获取进程PID, 需重新获取, 避免restart时无法正确启动。 - - if [ $APP_PID ]; then - echo " [$APP_NAME] App is running. this start fail. " - return 0 - fi + if [ $APP_PID ]; then + echo "[$APP_NAME] App is running. this start fail." + return 0 + fi nohup java -jar $APP_NAME >/dev/null 2>start.log & - # tail -200f start.log + # tail -200f start.log - echo " [$APP_NAME] App starting ... " + echo "[$APP_NAME] App starting ..." } # 停止 -function stop(){ - - getAppPID #获取进程PID +function stop() { + getAppPID # 获取进程PID + if [ ! $APP_PID ]; then + echo "[$APP_NAME] App is NOT running." + return 0 + fi - if [ ! $APP_PID ]; then - echo " [$APP_NAME] App is NOT running. " - return 0 - fi - - echo " [$APP_NAME] [pid=$APP_PID] [kill -15] stop process... " - kill -15 $APP_PID # kill-15 :正常退出程序 - - sleep 5 #等待5s + echo "[$APP_NAME] [pid=$APP_PID] [kill -15] stop process..." + kill -15 $APP_PID # kill-15 :正常退出程序 + sleep 5 # 等待5s - # 重新获取PID - refAppPID + # 重新获取PID + refAppPID - #仍然存在 需要kill -9 + # 仍然存在 需要kill -9 if [ $APP_PID ]; then - forcekill + forcekill fi - echo " [$APP_NAME] Stop Success! " - + echo "[$APP_NAME] Stop Success!" } # 检查 -function check(){ - - getAppPID #获取进程PID - - if [ $APP_PID ]; then - echo " [$APP_NAME] App is running. PID:[$APP_PID] " - else - echo " [$APP_NAME] App is NOT running. " - fi +function check() { + getAppPID # 获取进程PID + if [ $APP_PID ]; then + echo "[$APP_NAME] App is running. PID:[$APP_PID]" + else + echo "[$APP_NAME] App is NOT running." + fi } # 强制kill进程 -function forcekill(){ - - getAppPID #获取进程PID +function forcekill() { + getAppPID # 获取进程PID if [ $APP_PID ]; then - echo " [$APP_NAME] [pid=$APP_PID] [kill -9] Kill ing ... " + echo "[$APP_NAME] [pid=$APP_PID] [kill -9] Kill ing ..." kill -9 $APP_PID - echo " [$APP_NAME] [pid=$APP_PID] [kill -9] Kill Success! " - else - echo " [$APP_NAME] App is NOT running. " + echo "[$APP_NAME] [pid=$APP_PID] [kill -9] Kill Success!" + else + echo "[$APP_NAME] App is NOT running." fi - } echo '' - command=$1 -if [ "${command}" == "start" ]; then +if [ "${command}" == "start" ]; then start - -elif [ "${command}" == "stop" ]; then - stop - -elif [ "${command}" == "restart" ]; then - stop - start - -elif [ "${command}" == "check" ]; then - check - -elif [ "${command}" == "kill" ]; then - forcekill - +elif [ "${command}" == "stop" ]; then + stop +elif [ "${command}" == "restart" ]; then + stop + start +elif [ "${command}" == "check" ]; then + check +elif [ "${command}" == "kill" ]; then + forcekill else echo "Usage: $0 {start|stop|restart|check|kill|}" fi echo '' - -- Gitee From e1cf51de57bf29a9615565e606b603e09ff6c7f9 Mon Sep 17 00:00:00 2001 From: YangHongxiao <76406840@qq.com> Date: Mon, 24 Oct 2022 19:23:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[:rocket:]=E4=BC=98=E5=8C=96=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=98=BE=E7=A4=BA=E6=A0=BC=E5=BC=8F=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=98=BE=E7=A4=BA=E7=B1=BB=E5=AE=8C=E6=95=B4=E5=90=8D?= =?UTF-8?q?=E3=80=81=E6=96=B9=E6=B3=95=E5=90=8D=E3=80=81=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A1=8C=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jeepay-manager/src/main/resources/logback-spring.xml | 5 ++++- jeepay-merchant/src/main/resources/logback-spring.xml | 5 ++++- jeepay-payment/src/main/resources/logback-spring.xml | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/jeepay-manager/src/main/resources/logback-spring.xml b/jeepay-manager/src/main/resources/logback-spring.xml index 27c8b1e..43afe55 100644 --- a/jeepay-manager/src/main/resources/logback-spring.xml +++ b/jeepay-manager/src/main/resources/logback-spring.xml @@ -1,5 +1,7 @@ + + @@ -13,7 +15,8 @@ - + + diff --git a/jeepay-merchant/src/main/resources/logback-spring.xml b/jeepay-merchant/src/main/resources/logback-spring.xml index e902937..7239cad 100644 --- a/jeepay-merchant/src/main/resources/logback-spring.xml +++ b/jeepay-merchant/src/main/resources/logback-spring.xml @@ -1,5 +1,7 @@ + + @@ -13,7 +15,8 @@ - + + diff --git a/jeepay-payment/src/main/resources/logback-spring.xml b/jeepay-payment/src/main/resources/logback-spring.xml index d59a312..279d780 100644 --- a/jeepay-payment/src/main/resources/logback-spring.xml +++ b/jeepay-payment/src/main/resources/logback-spring.xml @@ -1,5 +1,7 @@ + + @@ -13,7 +15,8 @@ - + + -- Gitee