supervisor

This commit is contained in:
2025-09-18 11:44:01 +00:00
parent f156679578
commit b21ec21516
7 changed files with 46 additions and 8 deletions

View File

@@ -36,6 +36,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-xetex \ texlive-xetex \
texlive-science \ texlive-science \
libxml2-dev \ libxml2-dev \
supervisor \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
@@ -46,12 +47,15 @@ WORKDIR /app
# Copy requirements and install dependencies # Copy requirements and install dependencies
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r 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 the rest of the app
COPY . . COPY . .
# Expose the app port # Expose the app port
EXPOSE 8000 EXPOSE 8000
RUN chmod +x run.sh RUN chmod +x run.sh
# Command to run when container starts # Command to run when container starts
CMD ["./run.sh", "&"] #CMD ["./run.sh"]
CMD ["/usr/bin/supervisord", "-n"]

View File

@@ -750,4 +750,10 @@ async def health():
except Exception: except Exception:
logger.exception("Health check failed") logger.exception("Health check failed")
return JSONResponse({"ok": False}, status_code=500) return JSONResponse({"ok": False}, status_code=500)
return {"ok": True} 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)

View File

@@ -122,3 +122,4 @@ Werkzeug==3.1.3
wrapt==1.17.3 wrapt==1.17.3
xlrd==2.0.2 xlrd==2.0.2
xlsxwriter==3.2.9 xlsxwriter==3.2.9
supervisor

16
run.sh
View File

@@ -1,10 +1,14 @@
#!/bin/bash #!/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 & # Start Gunicorn in the background
echo "Done" gunicorn -w 4 --threads 2 -k uvicorn.workers.UvicornWorker --forwarded-allow-ips='*' main:app -b 0.0.0.0:8000 &
echo "Starting huey..." 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 exec huey_consumer.py main.huey -w 4
echo "Done" echo "Started Huey consumer..."

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
static/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

23
supervisor.conf Normal file
View File

@@ -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