mps-batch/MpsSimulationBatch/bin/start.sh

67 lines
2.1 KiB
Bash
Raw Normal View History

2025-09-13 16:31:45 +08:00
#!/bin/bash
# MPS模拟批量处理启动脚本
# 作者mps-batch
# 版本1.0
# 设置基础路径
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_HOME="$(dirname "$SCRIPT_DIR")"
JAR_FILE="$SCRIPT_DIR/mps-simulation-batch-jar-with-dependencies.jar"
CONF_DIR="$PROJECT_HOME/conf"
# 设置环境编码Linux生产环境
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8
# 设置Java参数
JAVA_OPTS="-Xms512m -Xmx1024m -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai"
JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=$PROJECT_HOME/src/main/resources/logback.xml"
JAVA_OPTS="$JAVA_OPTS -Dconfig.file=$CONF_DIR/application.properties"
# 从配置文件中读取日志路径并设置系统属性
if [ -f "$CONF_DIR/application.properties" ]; then
LOG_PATH_FROM_CONFIG=$(grep "^log.path=" "$CONF_DIR/application.properties" | cut -d'=' -f2)
if [ -n "$LOG_PATH_FROM_CONFIG" ]; then
JAVA_OPTS="$JAVA_OPTS -Dlog.path=$LOG_PATH_FROM_CONFIG"
echo "从配置文件读取日志路径: $LOG_PATH_FROM_CONFIG"
fi
fi
# 输出启动信息
echo "=================================================="
echo "MPS模拟批量处理程序"
echo "=================================================="
echo "项目路径: $PROJECT_HOME"
echo "JAR文件: $JAR_FILE"
echo "配置目录: $CONF_DIR"
echo "Java参数: $JAVA_OPTS"
echo "启动参数: $@"
echo "启动时间: $(date '+%Y-%m-%d %H:%M:%S')"
echo "=================================================="
# 检查JAR文件是否存在
if [ ! -f "$JAR_FILE" ]; then
echo "错误: JAR文件不存在 - $JAR_FILE"
echo "请先执行 'mvn clean package' 编译项目"
exit 1
fi
# 检查配置文件是否存在
if [ ! -f "$CONF_DIR/application.properties" ]; then
echo "错误: 配置文件不存在 - $CONF_DIR/application.properties"
exit 1
fi
# 运行Java程序
java $JAVA_OPTS -jar "$JAR_FILE" "$@"
# 获取退出状态
EXIT_CODE=$?
echo "=================================================="
echo "程序执行完毕,退出状态: $EXIT_CODE"
echo "结束时间: $(date '+%Y-%m-%d %H:%M:%S')"
echo "=================================================="
exit $EXIT_CODE