Files
pro_eld_mqtt_compare/bin/post-steps.sh

29 lines
976 B
Bash
Raw Normal View History

2025-07-18 10:02:28 +08:00
#!/bin/bash
2025-08-06 10:28:09 +08:00
#
#PORT=8889
#JAR_PATH="/home/zhangbiqiong/pro_eld_mqtt_compare/target/pro_eld_mqtt_compare-0.0.1-SNAPSHOT.jar"
#
## 检测端口是否被占用
#if netstat -tuln | grep -q ":$PORT"; then
# echo "Port $PORT is already in use. Not starting application."
# exit 0
#else
# echo "Port $PORT is free. Starting application..."
# nohup java -jar "$JAR_PATH" > /dev/null 2>&1 &
# echo "Application started with PID $!"
#fi
2025-07-18 10:02:28 +08:00
PORT=8889
2025-07-18 02:41:20 +00:00
JAR_PATH="/home/zhangbiqiong/pro_eld_mqtt_compare/target/pro_eld_mqtt_compare-0.0.1-SNAPSHOT.jar"
2025-08-06 10:28:09 +08:00
LOG_DIR="/home/zhangbiqiong/pro_eld_mqtt_compare/logs"
cd /home/zhangbiqiong/pro_eld_mqtt_compare || { echo "Failed to cd"; exit 1; }
2025-07-18 10:02:28 +08:00
if netstat -tuln | grep -q ":$PORT"; then
echo "Port $PORT is already in use. Not starting application."
exit 0
else
echo "Port $PORT is free. Starting application..."
2025-08-06 10:28:09 +08:00
nohup java -DLOG_HOME="$LOG_DIR" -jar "$JAR_PATH" > "$LOG_DIR/nohup.out" 2>&1 &
2025-07-18 10:02:28 +08:00
echo "Application started with PID $!"
2025-07-18 10:50:57 +08:00
fi