Files
Egutierrez 1dc09931b6 Initial extraction from fn_registry
sqlite_api: API REST HTTP read-only sobre registry.db y operations.db.
Bind por defecto 127.0.0.1:8484. Go + net/http + SQLite FTS5.

Extraido de fn_registry/projects/fn_monitoring/apps/sqlite_api/ como
repo independiente. La metadata del registry queda en project.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 20:23:30 +02:00

41 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start sqlite_api in the background. Logs to sqlite_api.log.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
REGISTRY_ROOT="$(cd "$SCRIPT_DIR/../../../.." && pwd)"
LOG="$SCRIPT_DIR/sqlite_api.log"
PID_FILE="$SCRIPT_DIR/sqlite_api.pid"
# Kill previous instance if running
if [ -f "$PID_FILE" ]; then
old_pid=$(cat "$PID_FILE")
if kill -0 "$old_pid" 2>/dev/null; then
echo "Stopping previous instance (PID $old_pid)"
kill "$old_pid"
sleep 0.5
fi
rm -f "$PID_FILE"
fi
export FN_REGISTRY_ROOT="$REGISTRY_ROOT"
cd "$REGISTRY_ROOT"
CGO_ENABLED=1 go run -tags fts5 ./projects/fn_monitoring/apps/sqlite_api/ "$@" \
>"$LOG" 2>&1 &
echo $! > "$PID_FILE"
echo "sqlite_api started (PID $!, log: $LOG)"
sleep 0.5
if curl -sf http://127.0.0.1:8484/health >/dev/null 2>&1; then
echo "Health check OK"
else
echo "Waiting for startup..."
sleep 1.5
if curl -sf http://127.0.0.1:8484/health >/dev/null 2>&1; then
echo "Health check OK"
else
echo "Warning: health check failed — check $LOG"
fi
fi