From 1ad240c7f9034179029cad6ac12420b943026630 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Mon, 29 Sep 2025 17:30:12 +0800 Subject: [PATCH] =?UTF-8?q?perf(linux):=20=E6=94=AF=E6=8C=81=E4=BB=8E?= =?UTF-8?q?=E4=BB=BB=E6=84=8F=E8=B7=AF=E5=BE=84=E6=89=A7=E8=A1=8C=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用 readlink 定位脚本真实路径 - 启动时自动切换到项目目录 --- novel-admin/src/main/build/scripts/novel-admin.sh | 7 +++++-- novel-crawl/src/main/build/scripts/novel-crawl.sh | 7 +++++-- novel-front/src/main/build/scripts/novel-front.sh | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/novel-admin/src/main/build/scripts/novel-admin.sh b/novel-admin/src/main/build/scripts/novel-admin.sh index 354f43f..2956619 100644 --- a/novel-admin/src/main/build/scripts/novel-admin.sh +++ b/novel-admin/src/main/build/scripts/novel-admin.sh @@ -5,9 +5,12 @@ JAR_NAME=$APP_NAME\.jar PID=$APP_NAME\.pid -#使用说明,用来提示输入参数 +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +cd "$SCRIPT_DIR"/.. || exit 1 + +# 使用说明 usage() { - echo "Usage: ./novel-admin.sh [start|stop|restart|status]" + echo "Usage: $0 [start|stop|restart|status]" exit 1 } diff --git a/novel-crawl/src/main/build/scripts/novel-crawl.sh b/novel-crawl/src/main/build/scripts/novel-crawl.sh index 1e7f148..a958ac4 100644 --- a/novel-crawl/src/main/build/scripts/novel-crawl.sh +++ b/novel-crawl/src/main/build/scripts/novel-crawl.sh @@ -5,9 +5,12 @@ JAR_NAME=$APP_NAME\.jar PID=$APP_NAME\.pid -#使用说明,用来提示输入参数 +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +cd "$SCRIPT_DIR"/.. || exit 1 + +# 使用说明 usage() { - echo "Usage: ./novel-crawl.sh [start|stop|restart|status]" + echo "Usage: $0 [start|stop|restart|status]" exit 1 } diff --git a/novel-front/src/main/build/scripts/novel-front.sh b/novel-front/src/main/build/scripts/novel-front.sh index c663072..f4eb4c7 100644 --- a/novel-front/src/main/build/scripts/novel-front.sh +++ b/novel-front/src/main/build/scripts/novel-front.sh @@ -4,10 +4,12 @@ JAR_NAME=$APP_NAME\.jar #PID 代表是PID文件 PID=$APP_NAME\.pid +SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +cd "$SCRIPT_DIR"/.. || exit 1 -#使用说明,用来提示输入参数 +# 使用说明 usage() { - echo "Usage: ./novel-front.sh [start|stop|restart|status]" + echo "Usage: $0 [start|stop|restart|status]" exit 1 }