fix systemd: use startup.sh instead of inline ExecStartPre
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 7s
Some checks failed
Deploy API Server / build-and-deploy (push) Failing after 7s
Multi-line Python in ExecStartPre is invalid systemd syntax. Extract pip install + reranker self-test into startup.sh. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
e0110fd8f8
commit
88a2162b62
21
rag-worker/startup.sh
Executable file
21
rag-worker/startup.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# zhixi-worker startup checks — called by systemd ExecStartPre
|
||||||
|
set -e
|
||||||
|
cd /opt/zhixi/backend/rag-worker
|
||||||
|
|
||||||
|
# Install any new dependencies
|
||||||
|
/usr/bin/python3.11 -m pip install -q -r requirements.txt \
|
||||||
|
-i https://mirrors.tencentyun.com/pypi/simple
|
||||||
|
|
||||||
|
# Self-test: reranker
|
||||||
|
/usr/bin/python3.11 -c "
|
||||||
|
import asyncio
|
||||||
|
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')
|
||||||
|
"
|
||||||
@ -9,19 +9,7 @@ WorkingDirectory=/opt/zhixi/backend/rag-worker
|
|||||||
Environment="PYTHONUNBUFFERED=1"
|
Environment="PYTHONUNBUFFERED=1"
|
||||||
EnvironmentFile=/opt/zhixi/backend/rag-worker/.env
|
EnvironmentFile=/opt/zhixi/backend/rag-worker/.env
|
||||||
|
|
||||||
# Install deps and self-test before starting main loop
|
ExecStartPre=/bin/bash /opt/zhixi/backend/rag-worker/startup.sh
|
||||||
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
|
ExecStart=/usr/bin/python3.11 -u main.py
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user