Compare commits
5 Commits
main
...
cj/agentap
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6b9800f8e | ||
|
|
9a320adf91 | ||
|
|
da17c9881a | ||
|
|
9029bd1555 | ||
|
|
82fb00a4e1 |
@ -3,30 +3,57 @@ set -o errexit
|
|||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
port=${1:-3284}
|
port=${1:-3284}
|
||||||
|
start_timeout=${2:-60}
|
||||||
|
listen_timeout=${3:-60}
|
||||||
|
|
||||||
# This script waits for the agentapi server to start on port 3284.
|
# This script waits for the agentapi server to start on port 3284.
|
||||||
# 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 process to start..."
|
||||||
for i in $(seq 1 150); do
|
start=$(date +%s)
|
||||||
for j in $(seq 1 3); do
|
while true; do
|
||||||
sleep 0.1
|
now=$(date +%s)
|
||||||
if curl -fs -o /dev/null "http://localhost:$port/status"; then
|
elapsed=$(( now - start ))
|
||||||
echo "agentapi response received ($j/3)"
|
if [[ "${elapsed}" -gt "${start_timeout}" ]]; then
|
||||||
else
|
echo "agentapi process not found after ${start_timeout} seconds"
|
||||||
echo "agentapi server not responding ($i/15)"
|
exit 1
|
||||||
continue 2
|
|
||||||
fi
|
fi
|
||||||
done
|
set +e
|
||||||
agentapi_started=true
|
agentapi_pid=$(pidof agentapi)
|
||||||
|
set -e
|
||||||
|
if [[ -z "${agentapi_pid}" ]]; then
|
||||||
|
echo "agentapi process not found (${elapsed}/${start_timeout})"
|
||||||
|
sleep 1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "agentapi process started with pid ${agentapi_pid} after ${elapsed} seconds"
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$agentapi_started" != "true" ]; then
|
echo "Waiting for agentapi to start listening on port ${port}..."
|
||||||
echo "Error: agentapi server did not start on port $port after 15 seconds."
|
start=$(date +%s)
|
||||||
|
while true; do
|
||||||
|
now=$(date +%s)
|
||||||
|
elapsed=$(( now - start ))
|
||||||
|
if [[ "${elapsed}" -gt "${listen_timeout}" ]]; then
|
||||||
|
echo "agentapi server not listening on port ${port} after ${listen_timeout} seconds"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
for j in $(seq 1 3); do
|
||||||
|
if curl -fs -o /dev/null "http://localhost:${port}/status"; then
|
||||||
|
echo "agentapi response received (${j}/3)"
|
||||||
|
sleep 0.1
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
echo "agentapi server not responding (${elapsed}/${listen_timeout})"
|
||||||
|
sleep 1
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "agentapi server started responding after ${elapsed} seconds"
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
echo "agentapi server started on port $port."
|
echo "agentapi server started on port ${port}."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user