feat(ocr): Implement persistent worker pool with SQLite job queue

Major OCR infrastructure improvements:
- Add persistent SQLite-based job queue for OCR tasks
- Implement worker pool with process isolation and auto-restart
- Add OCR engine selector dropdown (Tesseract/PaddleOCR) in upload zone
- Optimize Tesseract preprocessing based on benchmark results (8x faster)
- Add recognize_cif_optimized() with multi-strategy CIF extraction
- Add Romanian CIF checksum validation
- Increase Telegram long polling timeout from 10s to 30s

Squashed commits:
- feat(ocr): Implement persistent worker pool with SQLite job queue
- feat(ocr): Add OCR engine selector dropdown to upload zone
- perf(telegram): Increase long polling timeout from 10s to 30s
- perf(ocr): Optimize Tesseract preprocessing based on benchmark results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 12:32:12 +02:00
parent 00f826f7ed
commit 74f7aefc26
23 changed files with 3616 additions and 209 deletions

View File

@@ -46,11 +46,17 @@ check_port() {
cleanup() {
print_message "Stopping all services..."
# Stop run-with-restart.sh wrapper FIRST (prevents auto-restart)
print_message "Stopping backend restart wrapper..."
pkill -f "run-with-restart.sh" 2>/dev/null || true
sleep 1
# Stop Unified Backend (8000)
if check_port 8000; then
print_message "Stopping Unified Backend..."
lsof -ti:8000 | xargs kill -TERM 2>/dev/null || true
pkill -f "uvicorn main:app" 2>/dev/null || true
sleep 2
pkill -9 -f "uvicorn main:app" 2>/dev/null || true
lsof -ti:8000 | xargs kill -KILL 2>/dev/null || true
fi
@@ -152,8 +158,9 @@ else
cd - > /dev/null
# Wait for backend to start (Oracle pool + cache + Telegram bot initialization)
# OCR worker pre-warms in background (doesn't block startup)
print_message "Waiting for Unified Backend to initialize (Oracle + Cache + DBs + Telegram)..."
MAX_WAIT=35
MAX_WAIT=45
ELAPSED=0
while [ $ELAPSED -lt $MAX_WAIT ]; do
if check_port 8000; then