-
Notifications
You must be signed in to change notification settings - Fork 25
/
run_app_locally.sh
executable file
·46 lines (37 loc) · 1.36 KB
/
run_app_locally.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# VALIDATES IF WE HAVE CLOWDER ENV
TEMPDIR=`mktemp -d`
export ACG_CONFIG="./local_cdappconfig.json"
if [ -z "$ACG_CONFIG" ]; then
echo "Did not found ACG_CONFIG - RUNNING LOCALLY"
if [ -z "$INVENTORY_SVC_URL" ];
then echo "INVENTORY_SVC_URL is not set" && exit 1;
fi
if [ -z "$LOG_LEVEL" ];
then LOG_LEVEL='info'
fi
if [ -z "$NUM_WORKERS" ];
then NUM_WORKERS=2
fi
if [ -z "$THREADS" ];
then THREADS=2
fi
if [ -z "$PORT" ];
then PORT=8080
fi
if [ -z "$GUNICORN_REQUEST_FIELD_LIMIT" ];
then GUNICORN_REQUEST_FIELD_LIMIT=16380
fi
prometheus_multiproc_dir=$TEMPDIR gunicorn wsgi --worker-class uvicorn.workers.UvicornWorker -w $NUM_WORKERS --threads $THREADS -b 0.0.0.0:$PORT --log-level=$LOG_LEVEL --limit-request-field_size=$GUNICORN_REQUEST_FIELD_LIMIT --access-logfile=- --config ./gunicorn.conf.py
rm -rf $TEMPDIR
else
echo "Found ACG_CONFIG - RUNNING WITH CLOWDER"
export prometheus_multiproc_dir=$TEMPDIR
export LOG_LEVEL='debug'
PORT=8001
METRICS_PORT=9001
GUNICORN_REQUEST_FIELD_LIMIT=16380
APP_CONFIG='gunicorn.conf.py'
exec gunicorn wsgi --worker-class uvicorn.workers.UvicornWorker --reload --bind=0.0.0.0:"$PORT" --bind=0.0.0.0:"$METRICS_PORT" --log-level="$LOG_LEVEL" --limit-request-field_size=$GUNICORN_REQUEST_FIELD_LIMIT --access-logfile=- --config "$APP_CONFIG"
fi
rm -rf $TEMPDIR