api-server/rag-worker/zhixi-worker.service
WangDL e0110fd8f8
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 8s
fix CI: move Python deps + reranker test to systemd ExecStartPre
Runner container lacks Python 3.11, so pip install and self-test
now run as ExecStartPre in zhixi-worker.service on the host.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 16:25:52 +08:00

31 lines
898 B
Desktop File

[Unit]
Description=ZhiXi RAG Worker
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/opt/zhixi/backend/rag-worker
Environment="PYTHONUNBUFFERED=1"
EnvironmentFile=/opt/zhixi/backend/rag-worker/.env
# Install deps and self-test before starting main loop
ExecStartPre=/usr/bin/python3.11 -m pip install -q -r /opt/zhixi/backend/rag-worker/requirements.txt -i https://mirrors.tencentyun.com/pypi/simple
ExecStartPre=/usr/bin/python3.11 -c "
import asyncio, sys
from reranker import rerank
async def t():
r = await rerank('测试', ['这是测试文本', '无关内容'], top_n=1)
if not r: raise RuntimeError('reranker returned empty')
print(f'[self-test] reranker OK, score={r[0][\"score\"]:.4f}')
asyncio.run(t())
print('[self-test] all checks passed')
"
ExecStart=/usr/bin/python3.11 -u main.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target