Skip to content

Commit

Permalink
fix(scripts): correct bash conditional statement
Browse files Browse the repository at this point in the history
  • Loading branch information
mabw-rte committed Oct 10, 2024
1 parent a51a9cf commit c96bf80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ RUN ./scripts/install-debug.sh
RUN pip3 install --upgrade pip \
&& pip3 install -r /conf/requirements.txt


ENTRYPOINT ["./scripts/start.sh"]
30 changes: 15 additions & 15 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ min() {
workers=$(min 30 ${ANTARES_NB_WORKERS:-$((2*$(nproc) + 1))}) # default (2*nproc + 1) and max is 30

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

if [ -z "$1" ] ; then
sh $CUR_DIR/pre-start.sh
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
gunicorn --config $BASE_DIR/conf/gunicorn.py --worker-class=uvicorn.workers.UvicornWorker antarest.wsgi:app
elif [ "$use_uvicorn" = true ]; 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
else
export PYTHONPATH=$BASE_DIR
python3 $BASE_DIR/antarest/main.py -c $ANTAREST_CONF --module "$1"
Expand Down

0 comments on commit c96bf80

Please sign in to comment.