-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·55 lines (50 loc) · 1.38 KB
/
run.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
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
set -o pipefail
if test "x${APP}" = 'x'; then
export APP=dnsdigapi
fi
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux;;
Darwin*) machine=Mac;;
CYGWIN*) machine=Cygwin;;
MINGW*) machine=MinGw;;
*) machine="UNKNOWN:${unameOut}"
esac
if test "x${APP}" = 'xdnsdigapi'; then
# API Defaults
if test "x${PORT}" = 'x'; then
export PORT=8080
fi
if test "x${HOST}" = 'x'; then
export HOST=0.0.0.0
fi
if test "x${ENV}" = 'x'; then
export ENV=dev
fi
# Control number of workers for uvicorn
if test "x${WEB_CONCURRENCY}" = 'x'; then
echo 'WEB_CONCURRENCY is not set, setting it to number of cores'
if [ "$machine" == "Mac" ]; then
export WEB_CONCURRENCY=1
else
num_of_cores=$(nproc --all)
export WEB_CONCURRENCY=$num_of_cores
fi
fi
echo 'WEB_CONCURRENCY is: '"${WEB_CONCURRENCY}"
if test "x${ENV}" = 'xdev'; then
uvicorn dnsdig.appdnsdigapi.web:app --host $HOST --port $PORT --workers "$WEB_CONCURRENCY" --log-level info --reload
else
uvicorn dnsdig.appdnsdigapi.web:app --host $HOST --port $PORT --workers "$WEB_CONCURRENCY" --log-level info
fi
elif test "x${APP}" = 'xdnsdigd'; then
if test "x${PORT}" = 'x'; then
export PORT=5053
fi
if test "x${HOST}" = 'x'; then
export HOST=127.0.0.1
fi
python dnsdigd.py --host $HOST --port $PORT
fi