打包,以及linux上的位置
然后执行下面两个命令,一个多服务启动,一个是单服务启动
多服务启动命令
#!/bin/bash
# 设置JAR包的目录
JAR_DIR="/bpm/app_jar"
# 设置JAR包的名称,用空格分隔
# JAR_NAMES="platform-gateway.jar platform-authentication.jar platform-portal-svc.jar platform-flowengine-svc.jar platform-admin-svc.jar platform-runtime-svc.jar platform-designer-svc.jar platform-job-svc.jar platform-jobexecutor-svc.jar platform-cindare-svc.jar platform-logserver-svc.jar platform-springbootadmin.jar platform-msg-svc.jar platform-rules-svc.jar platform-registry.jar platform-file-svc.jar platform-mockserver.jar"
JAR_NAMES="platform-admin-svc.jar platform-portal-svc.jar platform-runtime-svc.jar platform-designer-svc.jar platform-rules-svc.jar"
start() {
for JAR_NAME in $JAR_NAMES; do
nohup java -server \
-Xms2048m -Xmx3072m \
-Xss1m \
-XX:MetaspaceSize=300m -XX:MaxMetaspaceSize=300m \
-XX:NewRatio=1 -XX:SurvivorRatio=8 \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/bpm/hprod/"${JAR_NAME%.*}"_%p.hprof \
-XX:ErrorFile=/bpm/logs/"${JAR_NAME%.*}"/java_error_%p.log \
-XX:+PrintGCDetails -Xloggc:/bpm/logs/"${JAR_NAME%.*}"_gc.log -XX:+PrintGCDateStamps \
-XX:-UseAdaptiveSizePolicy -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 -XX:InitiatingHeapOccupancyPercent=45 \
-XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:G1OldCSetRegionThresholdPercent=10 -XX:G1ReservePercent=10 -XX:MaxTenuringThreshold=15 \
-jar "$JAR_DIR/$JAR_NAME" >> /bpm/logs/"${JAR_NAME%.*}".log 2>&1 &
done
}
stop() {
for JAR_NAME in $JAR_NAMES; do
# 根据进程名杀死对应的Java进程
pkill -f "$JAR_NAME"
done
}
restart() {
stop
sleep 5
start
}
# 根据命令行参数执行相应的操作
case "$1" in
"start")
start
;;
"stop")
stop
;;
"restart")
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
单个的
nohup java -server \
-Xms8192m -Xmx8192m \
-Xss1m \
-XX:MetaspaceSize=300m -XX:MaxMetaspaceSize=300m \
-XX:NewRatio=1 -XX:SurvivorRatio=8 \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/bpm/hprod/platform-flowengine-svc_%p.hprof \
-XX:ErrorFile=/bpm/logs/platform-flowengine-svc/java_error_%p.log \
-XX:+PrintGCDetails -Xloggc:/bpm/logs/platform-flowengine-svc_gc.log -XX:+PrintGCDateStamps \
-XX:-UseAdaptiveSizePolicy -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 -XX:InitiatingHeapOccupancyPercent=45 \
-XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:G1OldCSetRegionThresholdPercent=10 -XX:G1ReservePercent=10 -XX:MaxTenuringThreshold=15 \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=9999 \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Djava.rmi.server.hostname=100.224.32.118 \
-Dcom.sun.management.jmxremote.rmi.port=9999 \
-jar /bpm/app_jar/platform-flowengine-svc.jar >> /bpm/logs/platform-flowengine-svc.jar.log 2>&1 &
命令执行
./xxx.sh --单个
./xxxx.sh start --多个
单个传命令的方式
#!/bin/bash
# 设置JAR包的目录
JAR_DIR="/bpm/app_jar"
# 功能函数定义
start() {
JAR_NAME=$1
echo "Starting $JAR_NAME..."
nohup java -server \
-Xms1024m -Xmx2048m \
-Xss1m \
-XX:MetaspaceSize=300m -XX:MaxMetaspaceSize=300m \
-XX:NewRatio=1 -XX:SurvivorRatio=8 \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/bpm/hprod/${JAR_NAME%.*}_%p.hprof \
-XX:ErrorFile=/bpm/logs/${JAR_NAME%.*}/java_error_%p.log \
-XX:+PrintGCDetails -Xloggc:/bpm/logs/${JAR_NAME%.*}_gc.log -XX:+PrintGCDateStamps \
-XX:-UseAdaptiveSizePolicy -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 -XX:InitiatingHeapOccupancyPercent=45 \
-XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:G1OldCSetRegionThresholdPercent=10 -XX:G1ReservePercent=10 -XX:MaxTenuringThreshold=15 \
-jar $JAR_DIR/$JAR_NAME >> /bpm/logs/${JAR_NAME%.*}.log 2>&1 &
echo "$JAR_NAME started."
}
stop() {
JAR_NAME=$1
echo "Stopping $JAR_NAME..."
pkill -f $JAR_DIR/$JAR_NAME
echo "$JAR_NAME stopped."
}
restart() {
JAR_NAME=$1
echo "Restarting $JAR_NAME..."
stop $JAR_NAME
sleep 5
start $JAR_NAME
echo "$JAR_NAME restarted."
}
# 主逻辑
if [ "$#" -ne 2 ]; then
echo "Usage: $0 {start|stop|restart} <jar-file-name>"
exit 1
fi
ACTION=$1
JAR_NAME=$2
case $ACTION in
start)
start $JAR_NAME
;;
stop)
stop $JAR_NAME
;;
restart)
restart $JAR_NAME
;;
*)
echo "Invalid command. Usage: $0 {start|stop|restart} <jar-file-name>"
exit 1
;;
esac
exit 0
使用
./start-new.sh restart platform-portal-svc.jar
jsp命令查看jar包的部署情况,更多详细的命令可以自行百度
查看日志
tail -300f platform-portal-svc.log