Skip to content

Commit

Permalink
refactor(scripts): add the possibility of using Gunicorn when speci…
Browse files Browse the repository at this point in the history
…fied
  • Loading branch information
mabw-rte committed Oct 7, 2024
1 parent 2aae23d commit 845917a
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,31 @@ min() {

workers=$(min 30 ${NB_WORKERS_ANTARES:-17}) # default to 17 and max is 30

# Check for --no-gunicorn or --multiple-ports argument
use_gunicorn=true
for arg in "$@"
do
if [[ $arg == "--no-gunicorn" || $arg == "--multiple-ports" ]]; then
use_gunicorn=false
break
fi
done

if [ -z "$1" ] ; then
sh $CUR_DIR/pre-start.sh
pids=() # Initialize empty array to store background process IDs
for ((i=0; i<workers; i++))
do
uvicorn antarest.wsgi:app --host 0.0.0.0 --port $((5000 + $i)) --log-level info --timeout-keep-alive 600 &
pids+=($!) # Store background process IDs
done
for pid in ${pids[*]};
do
wait $pid # Wait for each background process to finish
done
if [ "$use_gunicorn" = true ]; then
gunicorn --config $BASE_DIR/conf/gunicorn.py --worker-class=uvicorn.workers.UvicornWorker antarest.wsgi:app
else
pids=() # Initialize empty array to store background process IDs
for ((i=0; i<workers; i++))
do
uvicorn antarest.wsgi:app --host 0.0.0.0 --port $((5000 + $i)) --log-level info --timeout-keep-alive 600 &
pids+=($!) # Store background process IDs
done
for pid in ${pids[*]};
do
wait $pid # Wait for each background process to finish
done
else
export PYTHONPATH=$BASE_DIR
python3 $BASE_DIR/antarest/main.py -c $ANTAREST_CONF --module "$1"
Expand Down

0 comments on commit 845917a

Please sign in to comment.