Skip to content

Commit 8defcb2

Browse files
authored
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.
1 parent 14c43d9 commit 8defcb2

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

registry/coder/modules/agentapi/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The AgentAPI module is a building block for modules that need to run an AgentAPI
1616
```tf
1717
module "agentapi" {
1818
source = "registry.coder.com/coder/agentapi/coder"
19-
version = "2.1.0"
19+
version = "2.1.1"
2020
2121
agent_id = var.agent_id
2222
web_app_slug = local.app_slug

registry/coder/modules/agentapi/scripts/agentapi-wait-for-start.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ set -o errexit
33
set -o pipefail
44

55
port=${1:-3284}
6+
max_attempts=150
67

7-
# This script waits for the agentapi server to start on port 3284.
8+
# This script waits for the agentapi server to start on the given port.
9+
# Each attempt sleeps 0.1s, so 150 attempts ≈ 15 seconds.
810
# It considers the server started after 3 consecutive successful responses.
911

1012
agentapi_started=false
1113

1214
echo "Waiting for agentapi server to start on port $port..."
13-
for i in $(seq 1 150); do
15+
for i in $(seq 1 "$max_attempts"); do
1416
for j in $(seq 1 3); do
1517
sleep 0.1
1618
if curl -fs -o /dev/null "http://localhost:$port/status"; then
1719
echo "agentapi response received ($j/3)"
1820
else
19-
echo "agentapi server not responding ($i/15)"
21+
echo "agentapi server not responding ($i/$max_attempts)"
2022
continue 2
2123
fi
2224
done
@@ -25,7 +27,7 @@ for i in $(seq 1 150); do
2527
done
2628

2729
if [ "$agentapi_started" != "true" ]; then
28-
echo "Error: agentapi server did not start on port $port after 15 seconds."
30+
echo "Error: agentapi server did not start on port $port after $max_attempts attempts."
2931
exit 1
3032
fi
3133

0 commit comments

Comments
 (0)