-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrun_middle_layer
executable file
·41 lines (31 loc) · 1.14 KB
/
run_middle_layer
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
#! /bin/bash
set -o errexit
mode=$(grep "^mode: " Settings.yaml | sed "1s/mode: //")
m_port=$(grep "^m_port: " Settings.yaml | sed "1s/m_port: //")
m_num_processes=$(grep "^m_num_processes: " Settings.yaml | sed "1s/m_num_processes: //")
m_run_in_background=$(grep "^m_run_in_background: " Settings.yaml | sed "1s/m_run_in_background: //")
./build_back_ends ${mode}
export PATH=$PATH:~/.local/bin
cd middle_layer
server_name=gunicorn
if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then
server_name=uvicorn
fi
pid=`ps ax | grep ${server_name} | grep ${m_port} | awk '{split($0,a," "); print a[1]}' | head -n 1`
if [ -z "$pid" ]; then
echo "No ${server_name} daemon on ${m_port} ${m_port}"
else
kill $pid
echo "Killed ${server_name} daemon on ${m_port} ${m_port} - ($pid)"
fi
start_command="gunicorn main:app -b 127.0.0.1:${m_port} -w ${m_num_processes} -k uvicorn.workers.UvicornWorker"
if [[ "${server_name}" == "uvicorn" ]]
then
start_command="uvicorn main:app --host 127.0.0.1 --port ${m_port} --workers ${m_num_processes} --lifespan on"
fi
if [[ "${m_run_in_background}" = "yes" ]]
then
nohup ${start_command} &
else
${start_command}
fi