OCR Worker: add check and systemd install scripts.
This commit is contained in:
@@ -112,12 +112,18 @@ def run_ocr_on_bytes(content: bytes) -> dict:
|
||||
|
||||
@app.on_event("startup")
|
||||
def warmup():
|
||||
buf = __import__("io").BytesIO()
|
||||
Image.new("RGB", (120, 40), color=(255, 255, 255)).save(buf, format="JPEG")
|
||||
try:
|
||||
run_ocr_on_bytes(buf.getvalue())
|
||||
except Exception:
|
||||
pass
|
||||
"""延迟预热,不阻塞 HTTP 服务启动。"""
|
||||
import threading
|
||||
|
||||
def _run():
|
||||
buf = __import__("io").BytesIO()
|
||||
Image.new("RGB", (120, 40), color=(255, 255, 255)).save(buf, format="JPEG")
|
||||
try:
|
||||
run_ocr_on_bytes(buf.getvalue())
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
threading.Thread(target=_run, daemon=True, name="ocr-warmup").start()
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
|
||||
Reference in New Issue
Block a user