fix: 翻译主流程失败时 raise(不再返回占位符); add_usage TTL 用 replace(day=1) 防 0 TTL
This commit is contained in:
22
scripts/_redis2.py
Normal file
22
scripts/_redis2.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os, paramiko
|
||||
PW = os.environ["REMOTE_PASS"]
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("207.57.129.228", port=19717, username="root", password=PW, timeout=15, allow_agent=False, look_for_keys=False)
|
||||
def run(cmd, t=15):
|
||||
si, so, se = c.exec_command(cmd, timeout=t)
|
||||
out = so.read().decode("utf-8", "replace")
|
||||
err = se.read().decode("utf-8", "replace")
|
||||
rc = so.channel.recv_exit_status()
|
||||
if out: print(out, end="")
|
||||
if err: print("[err]", err, end="", file=__import__("sys").stderr)
|
||||
return out
|
||||
|
||||
rpw = run("grep ^REDIS_PASSWORD /srv/news/.env | cut -d= -f2").strip()
|
||||
# 看 translation:month
|
||||
print("--- 查 usage key ---")
|
||||
out = run(f"docker exec news-aggregator-redis-1 redis-cli -a '{rpw}' KEYS 'translation:month*' 2>&1 | grep -v Warning")
|
||||
print(out)
|
||||
out = run(f"docker exec news-aggregator-redis-1 redis-cli -a '{rpw}' GET 'translation:month:202606' 2>&1 | grep -v Warning")
|
||||
print(f" GET: {out.strip()}")
|
||||
c.close()
|
||||
Reference in New Issue
Block a user