File size: 934 Bytes
d31cb74
 
 
21eafbb
d31cb74
 
 
 
 
 
3580b8b
ff8eb49
3580b8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7131310
21eafbb
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
#!/usr/bin/env bash
set -euo pipefail

# venv activate
if [ -f "/home/user/app/.venv/bin/activate" ]; then
  source /home/user/app/.venv/bin/activate
fi

export PORT="${PORT:-7860}"

echo "[entrypoint] starting robot-server..."
(cd /root/opentrons && make -C robot-server dev-flex) > /tmp/robot-server.log 2>&1 &
ROBOT_SERVER_PID=$!
echo "[entrypoint] robot-server pid=${ROBOT_SERVER_PID}"

echo "[entrypoint] waiting for robot-server (127.0.0.1:31950)..."
for i in {1..60}; do
  if (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
    echo "[entrypoint] robot-server is up"
    break
  fi
  if ! kill -0 "${ROBOT_SERVER_PID}" >/dev/null 2>&1; then
    echo "[entrypoint] robot-server exited early. Last logs:"
    tail -n 200 /tmp/robot-server.log || true
    exit 1
  fi
  sleep 1
done

echo "[entrypoint] starting FastAPI on 0.0.0.0:${PORT} ..."
exec uvicorn api:app --app-dir /home/user/app --host 0.0.0.0 --port "${PORT}"