refactor: 移除心跳机制相关代码,简化服务器管理逻辑,更新文档以反映最新功能和配置
This commit is contained in:
@@ -22,12 +22,6 @@ class ServerRegistrationRequest(BaseModel):
|
||||
ws_url: str
|
||||
|
||||
|
||||
class ServerHeartbeatRequest(BaseModel):
|
||||
"""服务器心跳请求模型"""
|
||||
|
||||
name: str
|
||||
|
||||
|
||||
class ServerUnregisterRequest(BaseModel):
|
||||
"""服务器注销请求模型"""
|
||||
|
||||
@@ -41,7 +35,6 @@ class ServerStatusResponse(BaseModel):
|
||||
http_url: str
|
||||
ws_url: str
|
||||
status: str
|
||||
last_heartbeat: Optional[str] = None
|
||||
last_health_check: Optional[str] = None
|
||||
current_tasks: int
|
||||
max_concurrent_tasks: int
|
||||
@@ -74,25 +67,6 @@ async def register_server(request: ServerRegistrationRequest):
|
||||
raise HTTPException(status_code=500, detail=f"注册失败: {str(e)}")
|
||||
|
||||
|
||||
@router.post("/heartbeat", response_model=Dict[str, str])
|
||||
async def update_heartbeat(request: ServerHeartbeatRequest):
|
||||
"""更新服务器心跳"""
|
||||
try:
|
||||
success = await server_manager.update_server_heartbeat(request.name)
|
||||
|
||||
if success:
|
||||
return {
|
||||
"message": f"服务器 {request.name} 心跳更新成功",
|
||||
"status": "success",
|
||||
}
|
||||
else:
|
||||
raise HTTPException(status_code=404, detail=f"服务器 {request.name} 不存在")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"更新服务器 {request.name} 心跳时发生错误: {e}")
|
||||
raise HTTPException(status_code=500, detail=f"心跳更新失败: {str(e)}")
|
||||
|
||||
|
||||
@router.post("/unregister", response_model=Dict[str, str])
|
||||
async def unregister_server(request: ServerUnregisterRequest):
|
||||
"""注销ComfyUI服务器"""
|
||||
@@ -124,11 +98,6 @@ async def get_server_status(server_name: str):
|
||||
http_url=server_info.http_url,
|
||||
ws_url=server_info.ws_url,
|
||||
status=server_info.status.value,
|
||||
last_heartbeat=(
|
||||
server_info.last_heartbeat.isoformat()
|
||||
if server_info.last_heartbeat
|
||||
else None
|
||||
),
|
||||
last_health_check=(
|
||||
server_info.last_health_check.isoformat()
|
||||
if server_info.last_health_check
|
||||
@@ -157,9 +126,6 @@ async def list_all_servers():
|
||||
http_url=server.http_url,
|
||||
ws_url=server.ws_url,
|
||||
status=server.status.value,
|
||||
last_heartbeat=(
|
||||
server.last_heartbeat.isoformat() if server.last_heartbeat else None
|
||||
),
|
||||
last_health_check=(
|
||||
server.last_health_check.isoformat()
|
||||
if server.last_health_check
|
||||
|
||||
Reference in New Issue
Block a user