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))