@@ -31,6 +31,8 @@ CONSUMER_NO_BEG=0
3131CONSUMER_NO_END=0
3232WORKERS=1
3333GUNICORN_WORKERS=${GUNICORN_WORKERS:- 4} # Number of Gunicorn workers for the web server
34+ ENABLE_GUNICORN=${ENABLE_GUNICORN:- 1} # Whether to start the web server via Gunicorn
35+ GUNICORN_MODE=${GUNICORN_MODE:- gevent} # Gunicorn worker class (gevent or sync)
3436
3537MCP_HOST=" 127.0.0.1"
3638MCP_PORT=9382
@@ -185,38 +187,43 @@ if [[ "${ENABLE_WEBSERVER}" -eq 1 ]]; then
185187 echo " Starting nginx..."
186188 /usr/sbin/nginx
187189
188- echo " Starting ragflow_server with Gunicorn (Production Mode)..."
189- # Get host and port from environment variables or use defaults
190- RAGFLOW_HOST=${RAGFLOW_HOST_IP:- 0.0.0.0}
191- RAGFLOW_PORT=${RAGFLOW_HOST_PORT:- 9380}
192- GUNICORN_WORKERS=${GUNICORN_WORKERS:- 4}
193- GUNICORN_TIMEOUT=${GUNICORN_TIMEOUT:- 120}
194-
195- # Set environment variable for gevent worker class
196- export GUNICORN_WORKER_CLASS=gevent
197-
198- echo " Gunicorn config: Workers=${GUNICORN_WORKERS} , Host=${RAGFLOW_HOST} , Port=${RAGFLOW_PORT} , Worker Class=gevent"
199-
200- # Check if gunicorn config file exists and use it, otherwise use command line options
201- if [[ -f " /ragflow/conf/gunicorn.conf.py" ]]; then
202- echo " Using Gunicorn configuration file..."
203- exec gunicorn --config /ragflow/conf/gunicorn.conf.py ' api.wsgi:application'
190+ if [[ " ${ENABLE_GUNICORN} " -eq 1 ]]; then
191+ echo " Starting ragflow_server with Gunicorn (Production Mode)..."
192+ # Get host and port from environment variables or use defaults
193+ RAGFLOW_HOST=${RAGFLOW_HOST_IP:- 0.0.0.0}
194+ RAGFLOW_PORT=${RAGFLOW_HOST_PORT:- 9380}
195+ GUNICORN_WORKERS=${GUNICORN_WORKERS:- 4}
196+ GUNICORN_TIMEOUT=${GUNICORN_TIMEOUT:- 120}
197+
198+ # Set environment variable for worker class
199+ export GUNICORN_WORKER_CLASS=${GUNICORN_MODE}
200+
201+ echo " Gunicorn config: Workers=${GUNICORN_WORKERS} , Host=${RAGFLOW_HOST} , Port=${RAGFLOW_PORT} , Worker Class=${GUNICORN_MODE} "
202+
203+ # Check if gunicorn config file exists and use it, otherwise use command line options
204+ if [[ -f " /ragflow/conf/gunicorn.conf.py" ]]; then
205+ echo " Using Gunicorn configuration file..."
206+ exec gunicorn --config /ragflow/conf/gunicorn.conf.py ' api.wsgi:application'
207+ else
208+ echo " Using Gunicorn command line configuration..."
209+ # Start gunicorn with our WSGI application
210+ exec gunicorn --workers ${GUNICORN_WORKERS} \
211+ --worker-class ${GUNICORN_MODE} \
212+ --worker-connections 1000 \
213+ --max-requests 1000 \
214+ --max-requests-jitter 100 \
215+ --timeout ${GUNICORN_TIMEOUT} \
216+ --keep-alive 2 \
217+ --preload \
218+ --bind ${RAGFLOW_HOST} :${RAGFLOW_PORT} \
219+ --access-logfile - \
220+ --error-logfile - \
221+ --log-level info \
222+ ' api.wsgi:application'
223+ fi
204224 else
205- echo " Using Gunicorn command line configuration..."
206- # Start gunicorn with our WSGI application
207- exec gunicorn --workers ${GUNICORN_WORKERS} \
208- --worker-class gevent \
209- --worker-connections 1000 \
210- --max-requests 1000 \
211- --max-requests-jitter 100 \
212- --timeout ${GUNICORN_TIMEOUT} \
213- --keep-alive 2 \
214- --preload \
215- --bind ${RAGFLOW_HOST} :${RAGFLOW_PORT} \
216- --access-logfile - \
217- --error-logfile - \
218- --log-level info \
219- ' api.wsgi:application'
225+ echo " Starting ragflow_server in development mode..."
226+ exec " $PY " api/ragflow_server.py
220227 fi
221228fi
222229
0 commit comments