You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Start the Python strategy runtime, then hand PID 1's job to the agent.
#
# The agent cannot do anything useful without the runtime — it validates,
# backtests and ticks every strategy through it — so if the runtime dies the
# container must die too rather than serve a factory that silently stops
# evaluating. That is what the watchdog below enforces.
set -eu
python3 -m nectar_runtime.server &
RUNTIME_PID=$!
# Wait for it to bind before the agent starts probing.
i=0
while [ "$i" -lt 50 ]; do
if node -e "fetch('http://127.0.0.1:'+(process.env.RUNTIME_PORT||8799)+'/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))" 2>/dev/null; then
break
fi
i=$((i + 1))
sleep 0.2
done
# If the runtime exits at any point, take the whole container down. This polls
# rather than `wait`s: the watchdog runs in a subshell, which is not the
# runtime's parent, so `wait` there would return immediately and kill a
# perfectly healthy container.
(
while kill -0 "$RUNTIME_PID" 2>/dev/null; do
sleep 2
done
echo "strategy runtime exited — stopping the worker" >&2