diff --git a/Dockerfile b/Dockerfile index 3cdb743..646b6f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ texlive-xetex \ texlive-science \ libxml2-dev \ + supervisor \ && rm -rf /var/lib/apt/lists/* @@ -46,12 +47,15 @@ WORKDIR /app # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf # Copy the rest of the app COPY . . + # Expose the app port EXPOSE 8000 RUN chmod +x run.sh # Command to run when container starts -CMD ["./run.sh", "&"] +#CMD ["./run.sh"] +CMD ["/usr/bin/supervisord", "-n"] diff --git a/main.py b/main.py index 27b76de..6f678fd 100644 --- a/main.py +++ b/main.py @@ -750,4 +750,10 @@ async def health(): except Exception: logger.exception("Health check failed") return JSONResponse({"ok": False}, status_code=500) - return {"ok": True} \ No newline at end of file + return {"ok": True} + +favicon_path = PATHS.BASE_DIR / 'static' / 'favicon.png' + +@app.get('/favicon.ico', include_in_schema=False) +async def favicon(): + return FileResponse(favicon_path) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 09482a0..ec42d85 100644 --- a/requirements.txt +++ b/requirements.txt @@ -122,3 +122,4 @@ Werkzeug==3.1.3 wrapt==1.17.3 xlrd==2.0.2 xlsxwriter==3.2.9 +supervisor diff --git a/run.sh b/run.sh index 1476f1a..15d2a67 100755 --- a/run.sh +++ b/run.sh @@ -1,10 +1,14 @@ #!/bin/bash -# This script starts the FastAPI application using Gunicorn. -echo "Starting DocProcessor with Gunicorn on port 0.0.0.0:8000..." +# Exit immediately if a command exits with a non-zero status. +set -e -exec gunicorn -w 4 --threads 2 -k uvicorn.workers.UvicornWorker --forwarded-allow-ips='*' main:app -b 0.0.0.0:8000 & -echo "Done" -echo "Starting huey..." +# Start Gunicorn in the background +gunicorn -w 4 --threads 2 -k uvicorn.workers.UvicornWorker --forwarded-allow-ips='*' main:app -b 0.0.0.0:8000 & +echo "Started Gunicorn..." +# Store the Gunicorn process ID +GUNICORN_PID=$! +echo "Gunicorn PID: $GUNICORN_PID" +# Start the Huey consumer in the foreground exec huey_consumer.py main.huey -w 4 -echo "Done" +echo "Started Huey consumer..." \ No newline at end of file diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..dd5347d Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/favicon.png b/static/favicon.png new file mode 100644 index 0000000..6613b78 Binary files /dev/null and b/static/favicon.png differ diff --git a/supervisor.conf b/supervisor.conf new file mode 100644 index 0000000..6f3b2d4 --- /dev/null +++ b/supervisor.conf @@ -0,0 +1,23 @@ +[supervisord] +nodaemon=true +user=root + +[program:gunicorn] +command=gunicorn -w 4 --threads 2 -k uvicorn.workers.UvicornWorker --forwarded-allow-ips='*' main:app -b 0.0.0.0:8000 +directory=/app +autostart=true +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:huey] +command=huey_consumer.py main.huey -w 4 +directory=/app +autostart=true +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file