simplify entrypoint

This commit is contained in:
Shanyu Thibaut Juneja 2026-03-11 11:20:05 -07:00 committed by STJ
parent b880ed454c
commit d8b2a18425

View file

@ -333,22 +333,5 @@ done
echo "✅ Container ready"
# ---------------------------------------------------------------------------
# Instead of exec (which orphans background processes), run the user command
# and then wait so that the entrypoint stays alive as PID 1 to reap children.
# ---------------------------------------------------------------------------
cd /workspace
if [ $# -gt 0 ]; then
"$@" &
CMD_PID=$!
echo "Started user command (PID $CMD_PID): $*"
# Forward SIGTERM/SIGINT to all children for graceful shutdown
trap 'echo "Shutting down..."; kill $CMD_PID $TOOL_SERVER_PID $WATCHDOG_PID ${CHROMIUM_PID:-0} ${SOCAT_PID:-0} ${CAIDO_PID:-0} 2>/dev/null; wait' SIGTERM SIGINT
wait $CMD_PID
else
# No command: just keep running (wait on tool server)
trap 'echo "Shutting down..."; kill $TOOL_SERVER_PID $WATCHDOG_PID ${CHROMIUM_PID:-0} ${SOCAT_PID:-0} ${CAIDO_PID:-0} 2>/dev/null; wait' SIGTERM SIGINT
wait $TOOL_SERVER_PID
fi
exec "$@"