控制台改为选项卡,并支持封禁节点与下发计算任务。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,8 @@ def record_heartbeat(
|
||||
moment = now or utcnow()
|
||||
node = get_node_by_sn(session, sn.strip())
|
||||
assert_node_token(node, token)
|
||||
if node.is_banned:
|
||||
raise AppError("节点已封禁", 403)
|
||||
if node.license_expires_at <= moment:
|
||||
raise AppError("节点授权已到期", 403)
|
||||
bound_ip = (client_ip or "").strip() or None
|
||||
@@ -65,6 +67,18 @@ def record_heartbeat(
|
||||
return node
|
||||
|
||||
|
||||
def set_node_banned(session: Session, node: ComputeNode, banned: bool, now: datetime | None = None) -> ComputeNode:
|
||||
"""封禁立即结束在线区间。解除后要等下一次心跳才会重新上线。"""
|
||||
moment = now or utcnow()
|
||||
node.is_banned = banned
|
||||
node.updated_at = moment
|
||||
if banned and node.status == NodeStatus.ONLINE:
|
||||
_close_open_intervals(session, node.id, moment, "banned")
|
||||
node.status = NodeStatus.OFFLINE
|
||||
session.flush()
|
||||
return node
|
||||
|
||||
|
||||
def mark_stale_nodes(session: Session, now: datetime | None = None) -> list[str]:
|
||||
"""把超过心跳时限或授权已到期的在线节点置为 offline,并关闭在线区间。"""
|
||||
moment = now or utcnow()
|
||||
|
||||
Reference in New Issue
Block a user