feat: Enhance logging and error handling for job streaming and photo uploads
CI / skip-ci-check (pull_request) Successful in 8s
CI / lint-and-type-check (pull_request) Successful in 1m12s
CI / python-lint (pull_request) Successful in 36s
CI / test-backend (pull_request) Successful in 3m47s
CI / build (pull_request) Successful in 3m28s
CI / secret-scanning (pull_request) Successful in 14s
CI / dependency-scan (pull_request) Successful in 13s
CI / sast-scan (pull_request) Successful in 1m33s
CI / workflow-summary (pull_request) Successful in 5s
CI / skip-ci-check (pull_request) Successful in 8s
CI / lint-and-type-check (pull_request) Successful in 1m12s
CI / python-lint (pull_request) Successful in 36s
CI / test-backend (pull_request) Successful in 3m47s
CI / build (pull_request) Successful in 3m28s
CI / secret-scanning (pull_request) Successful in 14s
CI / dependency-scan (pull_request) Successful in 13s
CI / sast-scan (pull_request) Successful in 1m33s
CI / workflow-summary (pull_request) Successful in 5s
- Added new logging scripts for quick access to service logs and troubleshooting. - Updated job streaming API to support authentication via query parameters for EventSource. - Improved photo upload process to capture and validate EXIF dates and original modification times. - Enhanced error handling for file uploads and EXIF extraction failures. - Introduced new configuration options in ecosystem.config.js to prevent infinite crash loops.
This commit is contained in:
+23
-3
@@ -4,15 +4,17 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from fastapi import APIRouter, HTTPException, Query, status
|
||||
from fastapi.responses import StreamingResponse
|
||||
from rq import Queue
|
||||
from rq.job import Job
|
||||
from redis import Redis
|
||||
import json
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
from backend.schemas.jobs import JobResponse, JobStatus
|
||||
from backend.api.auth import get_current_user_from_token
|
||||
|
||||
router = APIRouter(prefix="/jobs", tags=["jobs"])
|
||||
|
||||
@@ -89,8 +91,26 @@ def get_job(job_id: str) -> JobResponse:
|
||||
|
||||
|
||||
@router.get("/stream/{job_id}")
|
||||
def stream_job_progress(job_id: str):
|
||||
"""Stream job progress via Server-Sent Events (SSE)."""
|
||||
def stream_job_progress(
|
||||
job_id: str,
|
||||
token: Optional[str] = Query(None, description="JWT token for authentication"),
|
||||
):
|
||||
"""Stream job progress via Server-Sent Events (SSE).
|
||||
|
||||
Note: EventSource cannot send custom headers, so authentication
|
||||
is done via query parameter 'token'.
|
||||
"""
|
||||
# Authenticate user via token query parameter (required for EventSource)
|
||||
if not token:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Authentication required. Provide 'token' query parameter.",
|
||||
)
|
||||
|
||||
try:
|
||||
get_current_user_from_token(token)
|
||||
except HTTPException as e:
|
||||
raise e
|
||||
|
||||
def event_generator():
|
||||
"""Generate SSE events for job progress."""
|
||||
|
||||
Reference in New Issue
Block a user