bfddfdfdfewe
This commit is contained in:
39
scripts/verify_enrich.py
Normal file
39
scripts/verify_enrich.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""30 秒后再连,看 enrich 是否开始干活"""
|
||||
import os, paramiko, time
|
||||
time.sleep(15) # 等等让它跑一会
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect("207.57.129.228", port=19717, username="root",
|
||||
password=os.environ["REMOTE_PASS"],
|
||||
timeout=30, allow_agent=False, look_for_keys=False)
|
||||
|
||||
|
||||
def run(label, cmd, timeout=30):
|
||||
print(f"\n=== {label} ===")
|
||||
try:
|
||||
si, so, se = c.exec_command(cmd, timeout=timeout)
|
||||
out = so.read().decode(errors="replace")
|
||||
err = se.read().decode(errors="replace")
|
||||
print(out.rstrip())
|
||||
if err.strip(): print(f"[stderr] {err.rstrip()}")
|
||||
except Exception as e:
|
||||
print(f"[exc] {type(e).__name__}: {e}")
|
||||
|
||||
|
||||
# 1) enrichment_loop 启动
|
||||
run("1) enrichment_loop 启动", "bash -lc 'cd /srv/news && docker compose logs --tail=50 worker 2>&1 | grep -iE \"enrich|started\" | head -20'")
|
||||
|
||||
# 2) enrich_article 日志(关键)
|
||||
run("2) enrich_article 日志", "bash -lc 'cd /srv/news && docker compose logs --tail=200 worker 2>&1 | grep -E \"enrich_article|classify|format ok|commentary ok\" | head -20'")
|
||||
|
||||
# 3) 当前 n/a 数
|
||||
run("3) 当前 n/a 数", "bash -lc 'cd /srv/news && docker compose exec -T postgres psql -U news -d news -c \"SELECT classify_status, count(*) FROM articles GROUP BY classify_status ORDER BY count(*) DESC;\"'")
|
||||
|
||||
# 4) 1 分钟后再看一次
|
||||
time.sleep(60)
|
||||
run("4) 1 分钟后 n/a 数", "bash -lc 'cd /srv/news && docker compose exec -T postgres psql -U news -d news -c \"SELECT classify_status, count(*) FROM articles GROUP BY classify_status ORDER BY count(*) DESC;\"'")
|
||||
|
||||
# 5) enrich_article 日志
|
||||
run("5) 1 分钟后 enrich_article 日志", "bash -lc 'cd /srv/news && docker compose logs --tail=100 worker 2>&1 | grep enrich_article | tail -20'")
|
||||
|
||||
c.close()
|
||||
Reference in New Issue
Block a user