From 68942cffb89f92258215c9bb70da4461786acd8e Mon Sep 17 00:00:00 2001 From: ENI Date: Sat, 7 Nov 2026 14:04:10 +0300 Subject: [PATCH] fix(sync): atomic token push with backup, no truncated pool on ssh drop --- sync_tokens.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sync_tokens.py b/sync_tokens.py index 7c9bf91..29d0362 100644 --- a/sync_tokens.py +++ b/sync_tokens.py @@ -47,7 +47,9 @@ def main(): uniq.append(r) payload = "\n".join(json.dumps(r, ensure_ascii=False) for r in uniq) + "\n" rc, out, err = sh(["ssh", "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=no", PROD, - "cat > %s && systemctl restart minara-shim && sleep 2 && curl -s -m 10 http://127.0.0.1:48140/health" % REMOTE], + ("cp -f %s %s.bak 2>/dev/null; cat > %s.tmp && mv -f %s.tmp %s && " + "systemctl restart minara-shim && sleep 2 && " + "curl -s -m 10 http://127.0.0.1:48140/health") % (REMOTE, REMOTE, REMOTE, REMOTE, REMOTE)], inp=payload) print("local=%d remote_before=%s rc=%d %s %s" % (len(uniq), remote_n, rc, out[:200], err))