mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(ci): trim docker e2e heartbeat latency
This commit is contained in:
@@ -76,7 +76,7 @@ docker_build_timeout_required() {
|
||||
docker_build_heartbeat_seconds() {
|
||||
local configured="${OPENCLAW_DOCKER_BUILD_HEARTBEAT_SECONDS:-30}"
|
||||
if [[ "$configured" =~ ^[0-9]+$ ]] && [ "$configured" -ge 1 ]; then
|
||||
echo "$configured"
|
||||
echo "$((10#$configured))"
|
||||
return
|
||||
fi
|
||||
echo 30
|
||||
|
||||
@@ -35,19 +35,29 @@ run_logged_print_heartbeat() {
|
||||
local label="$1"
|
||||
local interval_seconds="$2"
|
||||
shift 2
|
||||
if ! [[ "$interval_seconds" =~ ^[0-9]+$ ]] || [ "$interval_seconds" -lt 1 ]; then
|
||||
interval_seconds="30"
|
||||
else
|
||||
interval_seconds="$((10#$interval_seconds))"
|
||||
fi
|
||||
local log_file
|
||||
log_file="$(docker_e2e_run_log "$label")"
|
||||
"$@" >"$log_file" 2>&1 &
|
||||
local command_pid=$!
|
||||
local started_at
|
||||
started_at="$(date +%s)"
|
||||
local started_at="$SECONDS"
|
||||
local next_heartbeat=$interval_seconds
|
||||
local status=0
|
||||
while kill -0 "$command_pid" 2>/dev/null; do
|
||||
sleep "$interval_seconds"
|
||||
if kill -0 "$command_pid" 2>/dev/null; then
|
||||
local now
|
||||
now="$(date +%s)"
|
||||
echo "still running $label ($((now - started_at))s elapsed)"
|
||||
/bin/sleep 1
|
||||
local elapsed_seconds=$((SECONDS - started_at))
|
||||
if [ "$elapsed_seconds" -ge "$next_heartbeat" ] && kill -0 "$command_pid" 2>/dev/null; then
|
||||
local log_bytes="0"
|
||||
if [ -f "$log_file" ]; then
|
||||
log_bytes="$(wc -c <"$log_file" 2>/dev/null || echo 0)"
|
||||
log_bytes="${log_bytes//[[:space:]]/}"
|
||||
fi
|
||||
echo "still running $label (${elapsed_seconds}s elapsed, ${log_bytes} log bytes captured)"
|
||||
next_heartbeat=$((elapsed_seconds + interval_seconds))
|
||||
fi
|
||||
done
|
||||
set +e
|
||||
|
||||
Reference in New Issue
Block a user