# rysd-rtc **Repository Path**: starnow/rysd-rtc ## Basic Information - **Project Name**: rysd-rtc - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-12 - **Last Updated**: 2026-03-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LiveKit Stack 一个完整的LiveKit音视频服务栈,包含LiveKit服务器、Node.js API服务、Python WebSocket服务和Nginx代理,打包在单一Docker镜像中。 ## 架构概览 ``` ┌─────────────────────────────────────────────────────────────┐ │ LiveKit Stack Container │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Nginx │ │ LiveKit │ │ Redis │ │ │ │ (Port 80/443)│ │ (Port 7880-82)│ │ (Port 6379) │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ ├────────────────┼────────────────┤ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ │ │ │ Node.js │ │ Python │ │ │ │ API │ │ WebSocket │ │ │ │ (Port 3000) │ │(Port 8766) │ │ │ └─────────────┘ └─────────────┘ │ └─────────────────────────────────────────────────────────────┘ ``` ## 服务组件 ### 1. LiveKit服务器 - **端口**: 7880 (WebRTC), 7881 (HTTP), 7882 (TURN) - **功能**: 核心音视频服务器,处理WebRTC连接 ### 2. Redis缓存 - **端口**: 6379 - **功能**: LiveKit服务器的缓存和会话存储 ### 3. Node.js API服务 - **端口**: 3000 - **功能**: 基于LiveKit Server SDK的REST API服务 - **路由**: `/api/` ### 4. Python WebSocket服务 - **端口**: 8766 - **功能**: 处理WebSocket连接,转发音视频流到LiveKit - **路由**: `/ws/` ## 快速开始 ### 前置要求 - Docker 20.10+ ### 构建和启动 ```bash # 克隆项目 git clone cd livekit-stack # 构建镜像 ./build.sh # 启动服务 ./run.sh ``` ### 停止服务 ```bash ./stop-single.sh ``` ## 访问地址 | 服务 | 地址 | 说明 | |------|------|------| | 健康检查 | http://localhost/health | 服务状态检查 | | LiveKit WebRTC | ws://localhost/livekit/ | WebRTC连接 | | Node.js API | http://localhost/api/ | REST API服务 | | Python WebSocket | ws://localhost/ws/ | WebSocket服务 | | HTTPS | https://localhost/ | 安全连接 | ## 管理命令 ```bash # 查看容器状态 docker ps # 查看所有日志 docker logs -f livekit-stack # 进入容器 docker exec -it livekit-stack bash # 重启容器 docker restart livekit-stack # 停止容器 docker stop livekit-stack # 删除容器 docker rm livekit-stack # 健康检查 docker logs -f livekit-stack ``` ## 日志查看 ### 查看所有服务日志 ```bash # 进入容器查看各服务日志 docker exec -it livekit-stack bash # 查看各服务的日志文件 tail -f /var/log/supervisor/redis.log # Redis日志 tail -f /var/log/supervisor/livekit.log # LiveKit日志 tail -f /var/log/supervisor/nodejs.log # Node.js API日志 tail -f /var/log/supervisor/python.log # Python WebSocket日志 tail -f /var/log/supervisor/nginx.log # Nginx日志 tail -f /var/log/supervisor/health.log # 健康检查日志 ``` ### 使用Supervisor管理 ```bash # 进入容器 docker exec -it livekit-stack bash # 查看所有服务状态 supervisorctl status # 查看特定服务状态 supervisorctl status redis supervisorctl status livekit-server supervisorctl status nodejs-api supervisorctl status python-ws supervisorctl status nginx # 查看服务日志 supervisorctl tail redis supervisorctl tail livekit-server supervisorctl tail nodejs-api supervisorctl tail python-ws supervisorctl tail nginx ``` ### 直接从容器外查看日志 ```bash # 查看Redis日志 docker exec livekit-stack tail -f /var/log/supervisor/redis.log # 查看LiveKit日志 docker exec livekit-stack tail -f /var/log/supervisor/livekit.log # 查看Node.js API日志 docker exec livekit-stack tail -f /var/log/supervisor/nodejs.log # 查看Python WebSocket日志 docker exec livekit-stack tail -f /var/log/supervisor/python.log # 查看Nginx日志 docker exec livekit-stack tail -f /var/log/supervisor/nginx.log ``` ## 配置说明 ### LiveKit配置 (livekit.yaml) - 房间管理设置 - 媒体编码配置 - TURN服务器设置 - 监控和日志配置 ### Nginx配置 (nginx/nginx.conf) - 反向代理设置 - SSL/TLS配置 - 负载均衡 - 缓存和压缩 ### Supervisor配置 (supervisord.conf) - 进程管理配置 - 服务启动顺序 - 日志收集设置 - 自动重启策略 ## 开发模式 ### 本地开发 1. 修改源代码 2. 重新构建镜像 ```bash ./build.sh ./run.sh ``` ### 调试模式 ```bash # 查看实时日志 docker logs -f livekit-stack # 进入容器调试 docker exec -it livekit-stack bash # 查看服务状态 supervisorctl status ``` ## 故障排除 ### 常见问题 1. **端口冲突** ```bash # 检查端口占用 netstat -tulpn | grep :80 netstat -tulpn | grep :443 ``` 2. **SSL证书问题** ```bash # 重新构建镜像(会自动生成新证书) ./build.sh ./run.sh ``` 3. **服务启动失败** ```bash # 查看详细日志 docker logs livekit-stack # 进入容器检查服务状态 docker exec -it livekit-stack bash supervisorctl status ``` 4. **内存不足** ```bash # 增加Docker内存限制 # 在Docker Desktop中调整内存设置 ``` ### 日志位置 - **LiveKit**: `/var/log/supervisor/livekit.log` - **Node.js API**: `/var/log/supervisor/nodejs.log` - **Python WebSocket**: `/var/log/supervisor/python.log` - **Nginx**: `/var/log/supervisor/nginx.log` - **Redis**: `/var/log/supervisor/redis.log` ## 性能优化 ### 系统要求 - **CPU**: 4核心以上 - **内存**: 8GB以上 - **存储**: 20GB可用空间 - **网络**: 稳定的网络连接 ### 优化建议 1. **调整Docker资源限制** 2. **优化Nginx配置** 3. **调整LiveKit参数** 4. **监控系统资源使用** ## 安全考虑 1. **更改默认密钥** - 修改`livekit.yaml`中的API密钥 - 更新环境变量中的密钥配置 2. **配置防火墙** - 只开放必要的端口 - 限制访问来源 3. **使用HTTPS** - 替换自签名证书为真实证书 - 配置SSL/TLS安全策略 4. **定期更新镜像** - 定期重新构建镜像获取安全更新 - 监控依赖包的安全漏洞 5. **监控访问日志** - 定期检查Nginx访问日志 - 设置日志轮转和清理 ## 端口说明 | 端口 | 服务 | 说明 | |------|------|------| | 80 | Nginx | HTTP代理 | | 443 | Nginx | HTTPS代理 | | 7880 | LiveKit | WebRTC连接 | | 7881 | LiveKit | HTTP API | | 7882 | LiveKit | TURN服务器 | | 3000 | Node.js API | REST API服务 | | 8766 | Python WebSocket | WebSocket服务 | | 6379 | Redis | 缓存服务 | ## 许可证 MIT License ## 贡献 欢迎提交Issue和Pull Request!