修复工作
This commit is contained in:
@@ -5,11 +5,10 @@ services:
|
|||||||
image: redis:7-alpine
|
image: redis:7-alpine
|
||||||
container_name: ${REDIS_HOST}
|
container_name: ${REDIS_HOST}
|
||||||
restart: always
|
restart: always
|
||||||
command: redis-server --appendonly yes ${REDIS_PASSWORD:+--requirepass ${REDIS_PASSWORD}}
|
command: redis-server --appendonly yes --bind 127.0.0.1 ${REDIS_PASSWORD:+--requirepass ${REDIS_PASSWORD}}
|
||||||
|
network_mode: "host"
|
||||||
volumes:
|
volumes:
|
||||||
- redis-data:/data
|
- redis-data:/data
|
||||||
networks:
|
|
||||||
- rtsp-network
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: ["CMD", "redis-cli", "ping"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
@@ -22,13 +21,12 @@ services:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
container_name: ${PYTHON_SERVICE_HOST}
|
container_name: ${PYTHON_SERVICE_HOST}
|
||||||
restart: always
|
restart: always
|
||||||
|
network_mode: "host"
|
||||||
environment:
|
environment:
|
||||||
TZ: ${TZ}
|
TZ: ${TZ}
|
||||||
MODEL_DIR: /app/models
|
MODEL_DIR: /app/models
|
||||||
volumes:
|
volumes:
|
||||||
- ./python-inference-service/models:/app/models
|
- ./python-inference-service/models:/app/models
|
||||||
networks:
|
|
||||||
- rtsp-network
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
@@ -41,6 +39,7 @@ services:
|
|||||||
dockerfile: ruoyi-admin/Dockerfile
|
dockerfile: ruoyi-admin/Dockerfile
|
||||||
container_name: ${BACKEND_HOST}
|
container_name: ${BACKEND_HOST}
|
||||||
restart: always
|
restart: always
|
||||||
|
network_mode: "host"
|
||||||
depends_on:
|
depends_on:
|
||||||
redis:
|
redis:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -52,15 +51,13 @@ services:
|
|||||||
SPRING_DATASOURCE_URL: jdbc:mysql://${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DATABASE}?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
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_USERNAME: ${MYSQL_USER}
|
||||||
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
|
SPRING_DATASOURCE_PASSWORD: ${MYSQL_PASSWORD}
|
||||||
SPRING_DATA_REDIS_HOST: ${REDIS_HOST}
|
SPRING_DATA_REDIS_HOST: localhost
|
||||||
SPRING_DATA_REDIS_PORT: ${REDIS_PORT}
|
SPRING_DATA_REDIS_PORT: ${REDIS_PORT}
|
||||||
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD}
|
SPRING_DATA_REDIS_PASSWORD: ${REDIS_PASSWORD}
|
||||||
PYTHON_API_URL: http://${PYTHON_SERVICE_HOST}:${PYTHON_SERVICE_PORT}
|
PYTHON_API_URL: http://localhost:${PYTHON_SERVICE_PORT}
|
||||||
volumes:
|
volumes:
|
||||||
- backend-logs:/app/logs
|
- backend-logs:/app/logs
|
||||||
- backend-upload:/app/upload
|
- backend-upload:/app/upload
|
||||||
networks:
|
|
||||||
- rtsp-network
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
|
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
|
|||||||
@@ -45,5 +45,5 @@ EXPOSE 8000
|
|||||||
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
|
||||||
CMD curl -f http://localhost:8000/health || exit 1
|
CMD curl -f http://localhost:8000/health || exit 1
|
||||||
|
|
||||||
# 启动应用
|
# 启动应用(只监听本地,外网无法访问)
|
||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]
|
CMD ["uvicorn", "app.main:app", "--host", "127.0.0.1", "--port", "8000", "--workers", "1"]
|
||||||
@@ -9,9 +9,9 @@ server {
|
|||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 后端API代理
|
# 后端API代理(backend使用host网络)
|
||||||
location /prod-api/ {
|
location /prod-api/ {
|
||||||
proxy_pass http://rtsp-backend:8080/;
|
proxy_pass http://127.0.0.1:8080/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
@@ -23,7 +23,7 @@ server {
|
|||||||
|
|
||||||
# WebSocket支持(用于视频流)
|
# WebSocket支持(用于视频流)
|
||||||
location /websocket/ {
|
location /websocket/ {
|
||||||
proxy_pass http://rtsp-backend:8080/websocket/;
|
proxy_pass http://127.0.0.1:8080/websocket/;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
@@ -35,18 +35,18 @@ server {
|
|||||||
proxy_read_timeout 7d;
|
proxy_read_timeout 7d;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Python推理服务代理
|
# Python推理服务代理(映射到宿主机端口)
|
||||||
location /python-api/ {
|
location /python-api/ {
|
||||||
proxy_pass http://rtsp-python-service:8000/;
|
proxy_pass http://127.0.0.1:8000/;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 视频流代理(HTTP-FLV)
|
# 视频流代理(HTTP-FLV,backend使用host网络)
|
||||||
location /live {
|
location /live {
|
||||||
proxy_pass http://rtsp-backend:8866/live;
|
proxy_pass http://127.0.0.1:8866/live;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
@@ -54,11 +54,12 @@ server {
|
|||||||
proxy_set_header Connection "";
|
proxy_set_header Connection "";
|
||||||
proxy_buffering off;
|
proxy_buffering off;
|
||||||
proxy_cache off;
|
proxy_cache off;
|
||||||
|
chunked_transfer_encoding off;
|
||||||
}
|
}
|
||||||
|
|
||||||
# 视频流代理(HLS)
|
# 视频流代理(HLS)
|
||||||
location /hls {
|
location /hls {
|
||||||
proxy_pass http://rtsp-backend:8866/hls;
|
proxy_pass http://127.0.0.1:8866/hls;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ ruoyi:
|
|||||||
server:
|
server:
|
||||||
# 服务器的HTTP端口,默认为8080
|
# 服务器的HTTP端口,默认为8080
|
||||||
port: 8080
|
port: 8080
|
||||||
|
# 只监听本地地址,外网无法直接访问(通过Nginx代理)
|
||||||
|
address: ${SERVER_ADDRESS:127.0.0.1}
|
||||||
servlet:
|
servlet:
|
||||||
# 应用的访问路径
|
# 应用的访问路径
|
||||||
context-path: /
|
context-path: /
|
||||||
@@ -147,6 +149,8 @@ xss:
|
|||||||
# 流媒体服务端口
|
# 流媒体服务端口
|
||||||
mediasServer:
|
mediasServer:
|
||||||
port: 8866
|
port: 8866
|
||||||
|
# 只监听本地地址,外网无法直接访问(通过Nginx代理)
|
||||||
|
address: ${MEDIA_SERVER_ADDRESS:127.0.0.1}
|
||||||
# 网络超时,15秒
|
# 网络超时,15秒
|
||||||
netTimeout: 15000000
|
netTimeout: 15000000
|
||||||
# 读写超时,15秒
|
# 读写超时,15秒
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ public class InitServer implements CommandLineRunner {
|
|||||||
// 注入mediasServer.port的值
|
// 注入mediasServer.port的值
|
||||||
@Value("${mediasServer.port}")
|
@Value("${mediasServer.port}")
|
||||||
private int port;
|
private int port;
|
||||||
|
// 注入mediasServer.address的值(默认127.0.0.1,只监听本地)
|
||||||
|
@Value("${mediasServer.address:127.0.0.1}")
|
||||||
|
private String address;
|
||||||
// 注入MediaServer对象
|
// 注入MediaServer对象
|
||||||
@Autowired
|
@Autowired
|
||||||
private MediaServer mediaServer;
|
private MediaServer mediaServer;
|
||||||
@@ -100,8 +103,8 @@ public class InitServer implements CommandLineRunner {
|
|||||||
ip, port,
|
ip, port,
|
||||||
ip, httpPort,
|
ip, httpPort,
|
||||||
ip, httpPort);
|
ip, httpPort);
|
||||||
// 启动MediaServer
|
// 启动MediaServer(只监听配置的地址,默认127.0.0.1)
|
||||||
this.mediaServer.start(new InetSocketAddress("0.0.0.0", this.port));
|
this.mediaServer.start(new InetSocketAddress(this.address, this.port));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化自动播放
|
// 初始化自动播放
|
||||||
|
|||||||
Reference in New Issue
Block a user