baxin commited on
Commit
7131310
·
verified ·
1 Parent(s): 8131d9f

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +5 -10
entrypoint.sh CHANGED
@@ -6,17 +6,15 @@ if [ -f "/home/user/app/.venv/bin/activate" ]; then
6
  source /home/user/app/.venv/bin/activate
7
  fi
8
 
9
- export GRADIO_SERVER_NAME="${GRADIO_SERVER_NAME:-0.0.0.0}"
10
- export GRADIO_SERVER_PORT="${GRADIO_SERVER_PORT:-7860}"
11
  export PORT="${PORT:-7860}"
 
 
12
 
13
- # robot-server 起動(ログをファイルにも吐く)
14
  echo "[entrypoint] starting robot-server..."
15
- (cd /root/opentrons && make -C robot-server dev-flex) > /tmp/robot-server.log 2>&1 &
16
  ROBOT_SERVER_PID=$!
17
  echo "[entrypoint] robot-server pid=${ROBOT_SERVER_PID}"
18
 
19
- # 31950 が開くまで待つ(最大60秒)
20
  echo "[entrypoint] waiting for robot-server (127.0.0.1:31950)..."
21
  for i in {1..60}; do
22
  if (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
@@ -24,7 +22,6 @@ for i in {1..60}; do
24
  break
25
  fi
26
 
27
- # robot-server が落ちてたらログを出して終了
28
  if ! kill -0 "${ROBOT_SERVER_PID}" >/dev/null 2>&1; then
29
  echo "[entrypoint] robot-server exited early. Last logs:"
30
  tail -n 200 /tmp/robot-server.log || true
@@ -34,13 +31,11 @@ for i in {1..60}; do
34
  sleep 1
35
  done
36
 
37
- # 60秒待っても開かなければログを出して終了
38
  if ! (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
39
  echo "[entrypoint] robot-server did not start in time. Last logs:"
40
  tail -n 200 /tmp/robot-server.log || true
41
  exit 1
42
  fi
43
 
44
- echo "[entrypoint] starting main app..."
45
- exec python /home/user/app/main.py
46
-
 
6
  source /home/user/app/.venv/bin/activate
7
  fi
8
 
 
 
9
  export PORT="${PORT:-7860}"
10
+ export ROBOT_IP="${ROBOT_IP:-127.0.0.1}"
11
+ export ROBOT_PORT="${ROBOT_PORT:-31950}"
12
 
 
13
  echo "[entrypoint] starting robot-server..."
14
+ (cd /root/opentrons && make -C robot-server dev) > /tmp/robot-server.log 2>&1 &
15
  ROBOT_SERVER_PID=$!
16
  echo "[entrypoint] robot-server pid=${ROBOT_SERVER_PID}"
17
 
 
18
  echo "[entrypoint] waiting for robot-server (127.0.0.1:31950)..."
19
  for i in {1..60}; do
20
  if (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
 
22
  break
23
  fi
24
 
 
25
  if ! kill -0 "${ROBOT_SERVER_PID}" >/dev/null 2>&1; then
26
  echo "[entrypoint] robot-server exited early. Last logs:"
27
  tail -n 200 /tmp/robot-server.log || true
 
31
  sleep 1
32
  done
33
 
 
34
  if ! (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
35
  echo "[entrypoint] robot-server did not start in time. Last logs:"
36
  tail -n 200 /tmp/robot-server.log || true
37
  exit 1
38
  fi
39
 
40
+ echo "[entrypoint] starting FastAPI on 0.0.0.0:${PORT} ..."
41
+ exec uvicorn api:app --host 0.0.0.0 --port "${PORT}"