Skip to content

Commit

Permalink
perf(scripts): improve load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
mabw-rte committed Oct 2, 2024
1 parent 0bbfde5 commit 9cca518
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,18 @@ set -e
CUR_DIR=$(cd "$(dirname "$0")" && pwd)
BASE_DIR=$(dirname "$CUR_DIR")

min() {
echo $(( $1 < $2 ? $1 : $2 ))
}

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

if [ -z "$1" ] ; then
sh $CUR_DIR/pre-start.sh
gunicorn --config $BASE_DIR/conf/gunicorn.py --worker-class=uvicorn.workers.UvicornWorker antarest.wsgi:app
for ((i=0; i<workers; i++))
do
uvicorn antarest.wsgi:app --host 0.0.0.0 --port $((5000 + $i)) --log-level info --timeout 600 &
done
else
export PYTHONPATH=$BASE_DIR
python3 $BASE_DIR/antarest/main.py -c $ANTAREST_CONF --module "$1"
Expand Down

0 comments on commit 9cca518

Please sign in to comment.