代码拉取完成,页面将自动刷新
#!/bin/bash
# Function: Start, stop, restart, or check status of a JAR application
# Platform: All Linux Based Platforms
# Version: 1.1
# Date: 2023-03-XX
# Application details
APP_NAME="yudao-server-dev.jar"
DIR_NAME="/home/oa/dev"
JAR_PATH="$DIR_NAME/$APP_NAME"
LOG_FILE="$DIR_NAME/yudao-server-dev.log"
# Usage function
usage() {
echo "Usage: $0 [start|stop|restart|status]"
exit 1
}
# Check if the application is running
is_running() {
pid=$(pgrep -f "$JAR_PATH" | head -n 1)
if [ -z "$pid" ]; then
return 1
else
return 0
fi
}
# Start the application
start() {
if is_running; then
echo "$APP_NAME is already running. PID=$pid"
else
cd "$DIR_NAME"
nohup java -server -Xms512m -Xmx512m -jar "$JAR_PATH" > "$LOG_FILE" 2>&1 &
echo "$APP_NAME started successfully"
fi
}
# Stop the application
stop() {
if is_running; then
kill -9 "$pid"
echo "$APP_NAME stopped"
else
echo "$APP_NAME is not running"
fi
}
# Check the status of the application
status() {
if is_running; then
echo "$APP_NAME is running. PID=$pid"
else
echo "$APP_NAME is not running"
fi
}
# Restart the application
restart() {
stop
sleep 5
start
}
# Main logic
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
usage
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。