refactor: 移除日志实时流功能
删除 log_stream 模块及 LOG_TAIL_CTRL 命令、懒加载与停机释放逻辑,日志查看仅保留 LOG_TAIL 与 GET_LOG_DOWNLOAD。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
+1
-20
@@ -9,7 +9,7 @@ B 端通过 WebSocket 下发 JSON 命令:{"type":"CMD_TYPE","payload":{...}}
|
||||
- GET_VERSION 查询主程序版本
|
||||
- GET_LOG_FILES 日志文件列表
|
||||
- LOG_TAIL 日志尾部(payload: file, lines)
|
||||
- LOG_TAIL_CTRL 日志实时流开关(payload: action, file)
|
||||
- GET_LOG_DOWNLOAD 日志全量下载(payload: file)
|
||||
- RESTART 重启主程序(优雅停机后由 ProcessGuard 拉起)
|
||||
- GET_CONFIG 读取医院配置文件(payload: hospital)
|
||||
- SAVE_CONFIG 写回医院配置文件(payload: hospital, content)
|
||||
@@ -36,8 +36,6 @@ class CommandDispatcher:
|
||||
|
||||
self._client = None # 由 main 注入(避免构造环)
|
||||
self._upgrade_command = None # 升级命令(懒加载)
|
||||
self._log_stream = None # 日志实时流管理(懒加载)
|
||||
self._log_stream_lock = threading.Lock()
|
||||
self._upgrade_lock = threading.Lock()
|
||||
|
||||
def set_client(self, client):
|
||||
@@ -52,18 +50,6 @@ class CommandDispatcher:
|
||||
self._upgrade_command = UpgradeCommand(self.config, self.main_app_client, self._client)
|
||||
return self._upgrade_command
|
||||
|
||||
def _get_log_stream(self):
|
||||
"""懒加载日志流管理器。"""
|
||||
with self._log_stream_lock:
|
||||
if self._log_stream is None:
|
||||
from agent.log_stream import LogStreamManager
|
||||
self._log_stream = LogStreamManager(self.config, self.main_app_client, self._client)
|
||||
return self._log_stream
|
||||
|
||||
def shutdown_log_stream(self):
|
||||
"""日志实时流(供 main 停机时统一释放)。"""
|
||||
self._get_log_stream().stop_all()
|
||||
|
||||
# ================= 分发 =================
|
||||
|
||||
def dispatch(self, msg_type, payload):
|
||||
@@ -89,11 +75,6 @@ class CommandDispatcher:
|
||||
lines = (payload or {}).get("lines") or 200
|
||||
result = {"ok": True, "data": self.main_app_client.log_tail(file, lines)}
|
||||
|
||||
elif msg_type == "LOG_TAIL_CTRL":
|
||||
action = (payload or {}).get("action") or "start"
|
||||
file = (payload or {}).get("file") or "info.log"
|
||||
result = self._get_log_stream().control(action, file)
|
||||
|
||||
elif msg_type == "RESTART":
|
||||
# 优先走 NSSM 服务重启(主程序假死时 HTTP 不可达也能重启成功);
|
||||
# 未配置服务名时回退环回 HTTP 触发主程序优雅重启
|
||||
|
||||
Reference in New Issue
Block a user