服务迁移
This commit is contained in:
130
task/src/main/resources/application-dev-190.yml
Normal file
130
task/src/main/resources/application-dev-190.yml
Normal file
@@ -0,0 +1,130 @@
|
||||
# 前后端联调使用该配置文件,本地调试使用local
|
||||
server:
|
||||
port: 7102
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: task
|
||||
datasource:
|
||||
username: root
|
||||
password: mysql
|
||||
jdbc-url: jdbc:mysql://192.168.190.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
hikari:
|
||||
# 设置连接池能够容纳的最大连接数。建议值:CPU核心数 * 2 + 有效磁盘I/O数。一个常见的经验值是 10-20。
|
||||
maximum-pool-size: 20
|
||||
# 连接池在空闲时保持的最小连接数。
|
||||
minimum-idle: 5
|
||||
# 一个连接在被标记为空闲之前可以保持空闲状态的最长时间(毫秒)。当连接的空闲时间超过此值后,它可能会被连接池 evict(驱逐)。
|
||||
idle-timeout: 60000 # 1 min
|
||||
# 一个连接从被创建开始,其生命周期的最大时长(毫秒)。HikariCP的默认值就是30分钟,这是一个非常合理的设置。
|
||||
max-lifetime: 1800000 # 30 min(Hikari 默认)
|
||||
# 应用程序尝试从连接池获取一个连接时,等待的最长时间(毫秒)。建议值:30-60秒。
|
||||
connection-timeout: 30000 # 30s
|
||||
master:
|
||||
username: root
|
||||
password: mysql
|
||||
jdbc-url: jdbc:mysql://192.168.190.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
slave:
|
||||
username: root
|
||||
password: mysql
|
||||
jdbc-url: jdbc:mysql://192.168.190.161:3306/spdm_baseline?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
enable: true
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.190.161:8848
|
||||
group: DEV_GROUP
|
||||
# server-addr: 127.0.0.1:8848
|
||||
enabled: true
|
||||
# username: nacos
|
||||
# password: ENC(+QKYnI6gAYu1SbLaZQTkZA==)
|
||||
data:
|
||||
redis:
|
||||
# Redis默认情况下有16个分片(库),这里配置具体使用的分片,默认是0
|
||||
database: 0
|
||||
# redis服务器地址(填写自己的服务器地址)
|
||||
host: 192.168.2.166
|
||||
# redis端口(默认6379)
|
||||
port: 6379
|
||||
#redis连接超时等待,10秒
|
||||
timeout: PT10S
|
||||
# redis访问密码(默认为空)
|
||||
password:
|
||||
lettuce:
|
||||
pool:
|
||||
# 连接池最大连接数(使用负值表示没有限制) 默认 8
|
||||
max-active: 50
|
||||
# 连接池中的最大空闲连接 默认 8
|
||||
max-idle: 20
|
||||
# 连接池中的最小空闲连接 默认 0
|
||||
min-idle: 1
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1,这里配置10s
|
||||
max-wait: PT10S
|
||||
# password:
|
||||
# sentinel:
|
||||
# master: mymaster
|
||||
# nodes: 10.18.109.50:26379,10.18.109.51:26379,10.18.109.52:26379
|
||||
servlet:
|
||||
multipart:
|
||||
# 单个文件的最大值
|
||||
max-file-size: 500MB
|
||||
# 上传文件总的最大值
|
||||
max-request-size: 10240MB
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health,info
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
group:
|
||||
readiness:
|
||||
include: discoveryComposite,ping,refreshScope
|
||||
health:
|
||||
redis:
|
||||
enabled: false
|
||||
db:
|
||||
enabled: false
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
||||
auto-mapping-behavior: full
|
||||
# cache-enabled: true
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
mapper-locations: classpath*:mapper/**/*.xml
|
||||
global-config:
|
||||
# 逻辑删除配置
|
||||
db-config:
|
||||
# 删除前
|
||||
logic-not-delete-value: 1
|
||||
# 删除后
|
||||
logic-delete-value: 0
|
||||
|
||||
#showSql
|
||||
#logging:
|
||||
# level:
|
||||
# com.sdm.dao: debug
|
||||
|
||||
lombok:
|
||||
anyConstructor:
|
||||
addConstructorProperties: true
|
||||
|
||||
file:
|
||||
rootPath: /data/home/sdm
|
||||
scriptPath : /opt/script
|
||||
approve:
|
||||
replyUrl: http:192.168.190.161:7102/simulation/task/taskpool/approveHandleNotice
|
||||
#logging:
|
||||
# config: ./config/logback.xml
|
||||
|
||||
security:
|
||||
whitelist:
|
||||
paths:
|
||||
- /taskpool/approveHandleNotice
|
||||
- /taskPerformance/getRunPerformance
|
||||
12
task/src/main/resources/bin/190/log.sh
Normal file
12
task/src/main/resources/bin/190/log.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
# Spring Boot 项目日志查看脚本
|
||||
LOG_HOME="/home/app/task/logs"
|
||||
LOG_FILE="${LOG_HOME}/running.log"
|
||||
|
||||
# 查看实时日志
|
||||
if [ ! -f "${LOG_FILE}" ]; then
|
||||
echo "日志文件不存在:${LOG_FILE}(可能项目未启动)"
|
||||
exit 1
|
||||
fi
|
||||
echo "正在查看实时运行日志(按 Ctrl+C 退出)... 日志路径:${LOG_FILE}"
|
||||
tail -f "${LOG_FILE}"
|
||||
25
task/src/main/resources/bin/190/restart.sh
Normal file
25
task/src/main/resources/bin/190/restart.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# Spring Boot 项目重启脚本
|
||||
|
||||
# 定义基础路径(公共参数)
|
||||
BASE_DIR="/home/app/task"
|
||||
|
||||
echo "=== 开始重启项目 ==="
|
||||
|
||||
# 先停止服务
|
||||
if [ -f "${BASE_DIR}/stop.sh" ]; then
|
||||
"${BASE_DIR}/stop.sh"
|
||||
else
|
||||
echo "错误:未找到停止脚本 ${BASE_DIR}/stop.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 再启动服务
|
||||
if [ -f "${BASE_DIR}/start.sh" ]; then
|
||||
"${BASE_DIR}/start.sh"
|
||||
else
|
||||
echo "错误:未找到启动脚本 ${BASE_DIR}/start.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== 重启操作完成 ==="
|
||||
47
task/src/main/resources/bin/190/start.sh
Normal file
47
task/src/main/resources/bin/190/start.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
# Spring Boot 项目启动脚本
|
||||
JAR_PATH="/home/app/task"
|
||||
JAR_NAME="task-0.0.1-SNAPSHOT.jar"
|
||||
FULL_JAR_PATH="${JAR_PATH}/${JAR_NAME}"
|
||||
|
||||
# 与logback.xml保持一致的日志路径
|
||||
LOG_HOME="/home/app/task/logs"
|
||||
LOG_FILE="${LOG_HOME}/running.log"
|
||||
|
||||
# JVM参数
|
||||
JVM_OPTS="-Xms512m -Xmx1024m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_HOME}/heapdump.hprof"
|
||||
|
||||
# 检查Jar包是否存在
|
||||
check_jar_exists() {
|
||||
if [ ! -f "${FULL_JAR_PATH}" ]; then
|
||||
echo "ERROR: Jar包不存在!路径:${FULL_JAR_PATH}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 获取运行中的进程PID
|
||||
get_running_pid() {
|
||||
ps -ef | grep "${JAR_NAME}" | grep -v "grep" | awk '{print $2}'
|
||||
}
|
||||
|
||||
# 启动服务
|
||||
check_jar_exists
|
||||
|
||||
PID=$(get_running_pid)
|
||||
if [ -n "${PID}" ]; then
|
||||
echo "项目已在运行中!PID: ${PID}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 确保日志目录存在
|
||||
if [ ! -d "${LOG_HOME}" ]; then
|
||||
mkdir -p "${LOG_HOME}"
|
||||
echo "日志目录不存在,已自动创建:${LOG_HOME}"
|
||||
fi
|
||||
|
||||
echo "正在启动项目..."
|
||||
echo "======================================================================"
|
||||
|
||||
# 启动项目,保留控制台输出
|
||||
nohup java ${JVM_OPTS} -Dspring.profiles.active=dev-190 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5007 -jar "${FULL_JAR_PATH}" > "${LOG_FILE}" 2>&1 &
|
||||
|
||||
18
task/src/main/resources/bin/190/status.sh
Normal file
18
task/src/main/resources/bin/190/status.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
# Spring Boot 项目状态查看脚本
|
||||
JAR_NAME="task-0.0.1-SNAPSHOT.jar"
|
||||
LOG_HOME="/home/app/task/logs"
|
||||
LOG_FILE="${LOG_HOME}/running.log"
|
||||
|
||||
# 获取运行中的进程PID
|
||||
get_running_pid() {
|
||||
ps -ef | grep "${JAR_NAME}" | grep -v "grep" | awk '{print $2}'
|
||||
}
|
||||
|
||||
local PID=$(get_running_pid)
|
||||
if [ -n "${PID}" ]; then
|
||||
echo "项目运行中!PID: ${PID}"
|
||||
echo "日志文件路径:${LOG_FILE}"
|
||||
else
|
||||
echo "项目未在运行中"
|
||||
fi
|
||||
31
task/src/main/resources/bin/190/stop.sh
Normal file
31
task/src/main/resources/bin/190/stop.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Spring Boot 项目强制停止脚本
|
||||
JAR_NAME="task-0.0.1-SNAPSHOT.jar"
|
||||
|
||||
# 函数定义:获取运行中的进程ID
|
||||
get_running_pid() {
|
||||
ps -ef | grep "${JAR_NAME}" | grep -v "grep" | awk '{print $2}'
|
||||
}
|
||||
|
||||
# 获取进程ID
|
||||
PID=$(get_running_pid)
|
||||
|
||||
# 检查进程是否存在
|
||||
if [ -z "${PID}" ]; then
|
||||
echo "项目未在运行中,无需停止"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 强制停止进程
|
||||
echo "正在强制停止项目... PID: ${PID}"
|
||||
kill -9 "${PID}"
|
||||
|
||||
# 检查是否成功停止
|
||||
sleep 5
|
||||
if [ -z "$(get_running_pid)" ]; then
|
||||
echo "项目已强制停止成功"
|
||||
exit 0
|
||||
else
|
||||
echo "ERROR: 进程终止失败!请手动检查:ps -ef | grep ${JAR_NAME}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user