fix(agentapi): fix misleading attempt counter in wait-for-start script (#734)

The log message showed ($i/15) where $i ranged from 1-150, making it
look like the counter overshot its maximum. This change extracts the
iteration count into a max_attempts variable and uses it consistently.
This commit is contained in:
Zach 2026-02-18 09:13:22 -07:00 committed by GitHub
parent 14c43d9f29
commit 8defcb2410
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -16,7 +16,7 @@ The AgentAPI module is a building block for modules that need to run an AgentAPI
```tf ```tf
module "agentapi" { module "agentapi" {
source = "registry.coder.com/coder/agentapi/coder" source = "registry.coder.com/coder/agentapi/coder"
version = "2.1.0" version = "2.1.1"
agent_id = var.agent_id agent_id = var.agent_id
web_app_slug = local.app_slug web_app_slug = local.app_slug

View File

@ -3,20 +3,22 @@ set -o errexit
set -o pipefail set -o pipefail
port=${1:-3284} port=${1:-3284}
max_attempts=150
# This script waits for the agentapi server to start on port 3284. # This script waits for the agentapi server to start on the given port.
# Each attempt sleeps 0.1s, so 150 attempts ≈ 15 seconds.
# It considers the server started after 3 consecutive successful responses. # It considers the server started after 3 consecutive successful responses.
agentapi_started=false agentapi_started=false
echo "Waiting for agentapi server to start on port $port..." echo "Waiting for agentapi server to start on port $port..."
for i in $(seq 1 150); do for i in $(seq 1 "$max_attempts"); do
for j in $(seq 1 3); do for j in $(seq 1 3); do
sleep 0.1 sleep 0.1
if curl -fs -o /dev/null "http://localhost:$port/status"; then if curl -fs -o /dev/null "http://localhost:$port/status"; then
echo "agentapi response received ($j/3)" echo "agentapi response received ($j/3)"
else else
echo "agentapi server not responding ($i/15)" echo "agentapi server not responding ($i/$max_attempts)"
continue 2 continue 2
fi fi
done done
@ -25,7 +27,7 @@ for i in $(seq 1 150); do
done done
if [ "$agentapi_started" != "true" ]; then if [ "$agentapi_started" != "true" ]; then
echo "Error: agentapi server did not start on port $port after 15 seconds." echo "Error: agentapi server did not start on port $port after $max_attempts attempts."
exit 1 exit 1
fi fi