fix(llm+worker+deploy): 兼容老 prompt 模板 + 消除 startup_run 日志噪音

- enrichment: 新增 _safe_format (基于 _SafeDict),缺失占位符保留原样不抛 KeyError。
  _enrich_format / _enrich_classify / _enrich_image / _enrich_commentary
  全部走 _safe_format,数据库里老 prompt(不支持 {body})不再让整条 article 卡住。
  复现: 388183 classify 一直 KeyError,enrichment_loop 反复重试它,316 篇全卡在 n/a。
- workers.__main__: startup_run 从 IntervalTrigger(minutes=0) 改成 DateTrigger
  (只跑一次),消除 'maximum number of running instances reached' 刷屏 WARNING。
- deploy_pull: 改 _connect 自动识别 RSA / Ed25519 / ECDSA key(原硬编码 Ed25519Key)
This commit is contained in:
Mavis
2026-06-08 21:20:43 +08:00
parent 380e8b124e
commit 8d73f4fb28
3 changed files with 57 additions and 23 deletions

View File

@@ -44,7 +44,17 @@ def _run(c: paramiko.SSHClient, cmd: str, timeout: int = 60) -> tuple[int, str,
def _connect(host: str, port: int, user: str, ssh_key: str) -> paramiko.SSHClient:
pkey = paramiko.Ed25519Key.from_private_key_file(ssh_key)
# 依次尝试 RSA / Ed25519 / ECDSA(paramiko 5 没有统一入口)
pkey: Any = None
last_err: Exception | None = None
for loader in (paramiko.RSAKey, paramiko.Ed25519Key, paramiko.ECDSAKey):
try:
pkey = loader.from_private_key_file(ssh_key)
break
except Exception as e:
last_err = e
if pkey is None:
raise RuntimeError(f"无法解析 SSH key {ssh_key}: {last_err}")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(host, port=port, username=user, pkey=pkey, timeout=30,