Spaces:
Paused
Paused
File size: 1,430 Bytes
d31cb74 3580b8b d31cb74 3580b8b d31cb74 3580b8b |
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 |
#!/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
|