修复工作

This commit is contained in:
2025-09-30 20:10:34 +08:00
parent 8f4e25e895
commit e77a2f7cff
3 changed files with 17 additions and 4 deletions

7
.env
View File

@@ -1,4 +1,4 @@
# MySQL数据库配置使用远程MySQL通过IP地址直接连接
# MySQL数据库配置
MYSQL_HOST=49.232.154.205
MYSQL_PORT=10080
MYSQL_DATABASE=fad_watch
@@ -10,6 +10,9 @@ REDIS_HOST=rtsp-redis
REDIS_PORT=6379
REDIS_PASSWORD=
# 服务器配置(重要!前端访问视频流使用)
SERVER_HOST=49.232.154.205
# 后端服务配置
BACKEND_HOST=rtsp-backend
BACKEND_PORT=8080
@@ -21,7 +24,7 @@ FRONTEND_PORT=10080
PYTHON_SERVICE_HOST=rtsp-python-service
PYTHON_SERVICE_PORT=8000
# MinIO配置(外部服务)
# MinIO配置
MINIO_ENABLED=true
MINIO_ENDPOINT=http://49.232.154.205:10900
MINIO_ACCESS_KEY=4EsLD9g9OM09DT0HaBKj

View File

@@ -48,6 +48,7 @@ services:
condition: service_started
environment:
TZ: ${TZ}
SERVER_HOST: ${SERVER_HOST:-localhost}
SPRING_DATASOURCE_URL: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
SPRING_DATASOURCE_USERNAME: ${MYSQL_USER}
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}

View File

@@ -59,8 +59,17 @@ public class InitServer implements CommandLineRunner {
public void run(String... args) throws Exception {
// 初始化自动播放
this.initAutoPlay();
// TODO 获取本机IP地址
String ip = "localhost";
// 获取服务器IP地址支持环境变量配置
String ip = System.getenv("SERVER_HOST");
if (StrUtil.isEmpty(ip)) {
try {
// 尝试获取本机IP
InetAddress addr = InetAddress.getLocalHost();
ip = addr.getHostAddress();
} catch (Exception e) {
ip = "localhost";
}
}
// 获取http端口号
String httpPort = this.env.getProperty("server.port");
// 获取web路径