diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f2fe325b..3b931617 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -99,7 +99,8 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/apps/chart_demo/CMakeLists.txt) add_subdirectory(apps/chart_demo) endif() -# --- Registry Dashboard (lives in apps/ per project convention) --- -if(EXISTS ${CMAKE_SOURCE_DIR}/../apps/registry_dashboard/CMakeLists.txt) - add_subdirectory(${CMAKE_SOURCE_DIR}/../apps/registry_dashboard ${CMAKE_BINARY_DIR}/apps/registry_dashboard) +# --- Registry Dashboard (lives in projects/fn_monitoring/apps/) --- +set(_DASH_DIR ${CMAKE_SOURCE_DIR}/../projects/fn_monitoring/apps/registry_dashboard) +if(EXISTS ${_DASH_DIR}/CMakeLists.txt) + add_subdirectory(${_DASH_DIR} ${CMAKE_BINARY_DIR}/apps/registry_dashboard) endif() diff --git a/projects/fn_monitoring/apps/sqlite_api/start.sh b/projects/fn_monitoring/apps/sqlite_api/start.sh new file mode 100755 index 00000000..f8087772 --- /dev/null +++ b/projects/fn_monitoring/apps/sqlite_api/start.sh @@ -0,0 +1,40 @@ +#!/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