Add /admin/run-ingest endpoint for fallout retry
This commit is contained in:
@@ -108,6 +108,17 @@ def docker_reboot_host():
|
||||
docker_call("POST", "/containers/host-reboot/start", {})
|
||||
return status in (201, 409)
|
||||
|
||||
def docker_run_host_cmd(name, cmd_list):
|
||||
"""Run a command on the Ampère host via privileged nsenter container."""
|
||||
docker_call("DELETE", f"/containers/{name}?force=1")
|
||||
full_cmd = ["nsenter","-t","1","-m","-u","-i","-n","-p","--"] + cmd_list
|
||||
config = {"Image": "alpine", "Cmd": full_cmd,
|
||||
"HostConfig": {"Privileged": True, "PidMode": "host", "AutoRemove": True}}
|
||||
status, body = docker_call("POST", f"/containers/create?name={name}", config)
|
||||
if status in (201, 409):
|
||||
docker_call("POST", f"/containers/{name}/start", {})
|
||||
return status in (201, 409)
|
||||
|
||||
# ── SSH helpers (Guardian / Vigile) ───────────────────────────────────────
|
||||
SSH_KEYS = {
|
||||
"guardian": {"key": "/ssh/guardian.key", "host": "82.70.226.48"},
|
||||
@@ -358,6 +369,16 @@ class Handler(BaseHTTPRequestHandler):
|
||||
ok = ssh_reboot(vm)
|
||||
self.send_json({"ok":ok,"vm":vm})
|
||||
|
||||
elif p == "/admin/run-ingest":
|
||||
body = self.read_body()
|
||||
script = body.get("script","fallout")
|
||||
if script == "fallout":
|
||||
cmd = ["sh","-c","PYTHONUNBUFFERED=1 python3 -u /home/ubuntu/fallout/ingest.py >> /home/ubuntu/fallout/ingest.log 2>&1 &"]
|
||||
else:
|
||||
self.send_json({"ok":False,"error":"unknown script"}); return
|
||||
ok = docker_run_host_cmd("host-ingest", cmd)
|
||||
self.send_json({"ok":ok,"script":script})
|
||||
|
||||
else:
|
||||
self.send_response(404); self.end_headers()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user