ot_analysis / entrypoint.sh
baxin's picture
Update entrypoint.sh
3580b8b verified
#!/usr/bin/env bash
set -euo pipefail
# venv activate (あなたの app 用)
if [ -f "/home/user/app/.venv/bin/activate" ]; then
source /home/user/app/.venv/bin/activate
fi
export GRADIO_SERVER_NAME="${GRADIO_SERVER_NAME:-0.0.0.0}"
export GRADIO_SERVER_PORT="${GRADIO_SERVER_PORT:-7860}"
export PORT="${PORT:-7860}"
# robot-server 起動(ログをファイルにも吐く)
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}"
# 31950 が開くまで待つ(最大60秒)
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
# robot-server が落ちてたらログを出して終了
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
# 60秒待っても開かなければログを出して終了
if ! (echo > /dev/tcp/127.0.0.1/31950) >/dev/null 2>&1; then
echo "[entrypoint] robot-server did not start in time. Last logs:"
tail -n 200 /tmp/robot-server.log || true
exit 1
fi
echo "[entrypoint] starting main app..."
exec python /home/user/app/main.py