supervisor
This commit is contained in:
@@ -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"]
|
||||
|
||||
6
main.py
6
main.py
@@ -751,3 +751,9 @@ async def health():
|
||||
logger.exception("Health check failed")
|
||||
return JSONResponse({"ok": False}, status_code=500)
|
||||
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)
|
||||
@@ -122,3 +122,4 @@ Werkzeug==3.1.3
|
||||
wrapt==1.17.3
|
||||
xlrd==2.0.2
|
||||
xlsxwriter==3.2.9
|
||||
supervisor
|
||||
|
||||
16
run.sh
16
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..."
|
||||
BIN
static/favicon.ico
Normal file
BIN
static/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
static/favicon.png
Normal file
BIN
static/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
23
supervisor.conf
Normal file
23
supervisor.conf
Normal 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
|
||||
Reference in New Issue
Block a user