中控 Bridge 增加远程快速更新:/api/hub/version 与 /api/hub/update。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -388,6 +388,27 @@ def register_hub_bridge_routes(app: Flask, app_module: Any) -> None:
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
@app.route("/api/hub/version", methods=["GET"])
|
||||
def hub_version():
|
||||
"""中控探测客户端当前 git 版本/在线."""
|
||||
if not hub_bridge_token_ok(request.headers):
|
||||
return jsonify({"ok": False, "msg": "未授权"}), 401
|
||||
from lib.instance.instance_update_lib import read_git_version
|
||||
|
||||
ver = read_git_version()
|
||||
ver["online"] = True
|
||||
return jsonify(ver)
|
||||
|
||||
@app.route("/api/hub/update", methods=["POST"])
|
||||
def hub_update():
|
||||
"""中控远程快速更新:git pull + pm2 restart(异步)."""
|
||||
if not hub_bridge_token_ok(request.headers):
|
||||
return jsonify({"ok": False, "msg": "未授权"}), 401
|
||||
from lib.instance.instance_update_lib import schedule_pull_and_restart
|
||||
|
||||
out = schedule_pull_and_restart(delay_seconds=1.5)
|
||||
return jsonify(out), (200 if out.get("ok") else 400)
|
||||
|
||||
@app.route("/api/hub/backup/list", methods=["GET"])
|
||||
def hub_backup_list():
|
||||
if not hub_bridge_token_ok(request.headers):
|
||||
|
||||
Reference in New Issue
Block a user