chore(video): ZLM 凭证挪出默认配置 + 连接池 keep-alive + 日志/队列开关

- application.yaml 里的 media.id/ip/http-port/secret/auto-config 改用
  ${ZLM_*:占位} 形式,secret 默认值 please-override-in-env,防止
  真实凭证写进默认 profile 被全环境继承;开发机实际值搬到
  application-local.yaml,继续支持 env var 覆盖。已泄露到 git 历史
  的 secret 需运维侧单独旋转。
- application-local.yaml druid 池:min-evictable-idle 从 10min 降到
  5min + 打开 keep-alive,配合 eviction 扫描主动 ping,解决远程
  MySQL 经 NAT/云防火墙 60~80s 静默断开导致
  Communications link failure / last packet received X ms ago。
- application.yaml 补两个 video 模块运维开关:
    · viewsh.access-log.exclude-paths 屏蔽 /index/hook/on_server_keepalive
      心跳刷屏,出错仍会 WARN;
    · video.sip-queue.enabled 管控上一笔 commit 引入的三个
      SIP 消息 QueueScheduler,默认开启,关闭后队列会在内存堆积
      需要运维兜底(注释已提醒慎用)。
This commit is contained in:
lzh
2026-04-23 15:14:00 +08:00
parent 42d53bb02d
commit 10ea5e5eee
2 changed files with 36 additions and 7 deletions

View File

@@ -49,12 +49,18 @@ spring:
max-active: 20 # 最大连接池数量
max-wait: 60000 # 配置获取连接等待超时的时间单位毫秒1 分钟)
time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测检测需要关闭的空闲连接单位毫秒1 分钟)
min-evictable-idle-time-millis: 600000 # 配置一个连接在池中最小生存的时间单位毫秒10 分钟)
# 远程 MySQL124.222.218.x经 NAT/云防火墙,空闲 60~80s 会被中间层静默断开。
# 从 10 分钟改为 5 分钟:连接空闲达到这个阈值后开始走 keepAlive/回收逻辑。
min-evictable-idle-time-millis: 300000 # 连接在池中最小生存时间5 分钟)
max-evictable-idle-time-millis: 1800000 # 配置一个连接在池中最大生存的时间单位毫秒30 分钟)
validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效
test-while-idle: true
test-on-borrow: false
test-on-return: false
# keep-alive: 每次 eviction 扫描60s时主动 ping 空闲超过 min-evictable-idle 的连接,
# 死连接直接剔除,避免 @Scheduled 任务低频借连接时踩上被中间层静默断开的死连接,
# 症状RecoverableDataAccessException / Communications link failure / last packet received X ms ago
keep-alive: true
pool-prepared-statements: true # 是否开启 PreparedStatement 缓存
max-pool-prepared-statement-per-connection-size: 20 # 每个连接缓存的 PreparedStatement 数量
primary: master
@@ -115,6 +121,15 @@ spring:
username: admin
password: admin
--- #################### 本地开发专用ZLM 媒体服务器配置 ####################
# 生产/测试环境请通过环境变量 ZLM_* 覆盖,不要直接把本地值改进 application.yaml
media:
id: ${ZLM_SERVER_ID:zlmediakit-local}
ip: ${ZLM_IP:192.168.0.104}
http-port: ${ZLM_HTTP_PORT:9092}
secret: ${ZLM_SECRET:u3UapOhmZa9er7S37Hc2k695NlZOBYdB}
auto-config: ${ZLM_AUTO_CONFIG:false}
# 日志文件配置
logging:
level:

View File

@@ -108,6 +108,10 @@ viewsh:
web:
admin-ui:
url: http://dashboard.viewsh.iocoder.cn # Admin 管理后台 UI 的地址
# 访问日志:关掉 ZLM 每 10s 一次的心跳刷屏;出现异常或 4xx/5xx 时仍会打 WARN
access-log:
exclude-paths:
- /index/hook/on_server_keepalive
xss:
enable: false
exclude-urls:
@@ -149,17 +153,19 @@ sip:
register-time-interval: 60
# ZLMediaKit 默认服务器配置
# 真实连接参数ip/http-port/secret请通过环境变量或 application-{profile}.yaml 覆盖,
# 不要把具体环境的 secret 提交到默认 yaml。参考 application-local.yaml 里 MYSQL_* 的写法。
media:
# ZLM 服务器唯一 ID对应 ZLM general.mediaServerId
id: your-zlm-server-id
id: ${ZLM_SERVER_ID:your-zlm-server-id}
# ZLM 服务器内网 IP
ip: 127.0.0.1
ip: ${ZLM_IP:127.0.0.1}
# ZLM HTTP 端口
http-port: 80
# ZLM Hook 鉴权 secret对应 ZLM hook.admin_params=secret
secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
http-port: ${ZLM_HTTP_PORT:80}
# ZLM Hook 鉴权 secret对应 ZLM hook.admin_params=secret——必须通过环境/profile 覆盖
secret: ${ZLM_SECRET:please-override-in-env}
# 是否自动配置 ZLM
auto-config: true
auto-config: ${ZLM_AUTO_CONFIG:true}
# 录像路径
record-path: ./www/record
# 录像保存天数
@@ -226,4 +232,12 @@ user-settings:
# SIP 保持服务器连接false 可防止 TCP DoS 攻击,但降低性能)
sip-cache-server-connections: true
# Video 模块定时任务统一配置
# 项目的业务级定时任务走 xxl-jobxxl.job.*),此处管控 video 模块内高频 SIP 消息队列轮询
# 这类轮询频率50ms/100ms/200ms远低于 xxl-job 的秒级调度精度,仅靠 Spring @Scheduled 承载
video:
sip-queue:
# 是否开启 SIP 消息队列消费调度器(目录同步/心跳/报警)。关闭后 SIP 消息将堆积在内存队列,不落库,慎用
enabled: true
debug: false