2a3d780347
Adds `fn doctor` read-only diagnostic command with subcommands artefacts, services, sync, uses-functions, unused, and --json flag for agents. Each subcommand wraps a registry function in functions/infra/. New functions: - artefact_doctor, services_status, pc_locations_drift, audit_uses_functions, find_unused_functions (Go diagnostics) - backup_sqlite_db, rotate_backups, wait_for_http, wait_for_port, port_kill, tail_journal, pre_commit_hook_install (bash utilities) - notify_telegram (Go HTTP) - backup_all pipeline (tag launcher) Plus prior session leftovers (scan_secrets_in_dirty, append_diary_entry, git utilities, http_session_cookie_middleware, compile/full-git pipelines). Fixes pc_locations_drift filepath.Join bug with absolute dir_path. Documents fn doctor in CLAUDE.md, .claude/rules/fn_doctor.md (rule 23), docs/architecture.md, CHANGELOG.md (2026-05-07), and diary entry. First fn doctor uses-functions run found drift in 7/12 apps (deuda para sincronizar app.md con imports reales). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
# wait_for_http — polling HTTP hasta 200/2xx o timeout
|
|
|
|
wait_for_http() {
|
|
local url="${1:-}"
|
|
local timeout="${2:-30}"
|
|
local interval="${3:-1}"
|
|
|
|
# Validar dependencia
|
|
if ! command -v curl &>/dev/null; then
|
|
echo "wait_for_http: curl no encontrado" >&2
|
|
return 5
|
|
fi
|
|
|
|
# Validar URL
|
|
if [[ -z "$url" || ( "$url" != http://* && "$url" != https://* ) ]]; then
|
|
echo "wait_for_http: URL invalida — debe empezar por http:// o https://" >&2
|
|
return 2
|
|
fi
|
|
|
|
local start
|
|
start=$(date +%s)
|
|
local last_code="none"
|
|
|
|
while true; do
|
|
local now
|
|
now=$(date +%s)
|
|
local elapsed=$(( now - start ))
|
|
|
|
if (( elapsed >= timeout )); then
|
|
echo "TIMEOUT $url after ${timeout}s, last code: $last_code" >&2
|
|
return 1
|
|
fi
|
|
|
|
local code
|
|
code=$(curl -fsS -o /dev/null -w "%{http_code}" --max-time 5 "$url" 2>/dev/null || true)
|
|
last_code="${code:-000}"
|
|
|
|
echo ". waiting $url code=$last_code elapsed=${elapsed}s" >&2
|
|
|
|
# 2xx => OK
|
|
if [[ "$last_code" =~ ^2[0-9]{2}$ ]]; then
|
|
local finish
|
|
finish=$(date +%s)
|
|
local total=$(( finish - start ))
|
|
echo "OK $url (${total}s)"
|
|
return 0
|
|
fi
|
|
|
|
sleep "$interval"
|
|
done
|
|
}
|