diff --git a/entrypoint.sh b/entrypoint.sh index 86fbac5..14c69d2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,4 +24,21 @@ if [ ! -f "$DB" ]; then echo "[entrypoint] initialized $DB from seed snapshot" fi +# Arm the ingest/synthesis worker once the server answers. +# The Next standalone build has instrumentationHook disabled, so node-cron +# only starts when a request reaches /api/worker/ping. Pinging ourselves +# after boot means a fresh container or restart re-arms the worker (and +# triggers the boot pipeline pass) without any external health pinger. +( + APP_IP="$(hostname -i 2>/dev/null | awk '{print $1}')" + [ -z "$APP_IP" ] && APP_IP=127.0.0.1 + i=0 + until curl -sf -o /dev/null --max-time 2 "http://${APP_IP}:${PORT:-3000}/api/worker/ping"; do + i=$((i + 1)) + [ "$i" -ge 90 ] && exit 0 + sleep 1 + done + echo "[entrypoint] armed cron worker via /api/worker/ping" +) >/dev/null 2>&1 & + exec node server.js