feat: volume-based catalog refresh with hot-reload
- modules.py: check /data/ volume first, then baked-in /bicep_modules_catalog.json - server.py: add POST /reload endpoint — reloads catalogs without restart - ilsp.nomad: add 'ilsp-data' host volume mounted at /data - Makefile: add push-catalogs, health-prod, run-with-data targets; DEVOPS_MCP_REPO var - scripts/push_catalogs.sh: SCP both catalogs to autobox + call /reload Workflow: sync scripts on Mac → make push-catalogs → completions live in <5s
This commit is contained in:
61
scripts/push_catalogs.sh
Executable file
61
scripts/push_catalogs.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
# push_catalogs.sh — Push fresh Bicep + IAC source catalogs to autobox iLSP volume
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/push_catalogs.sh # push both catalogs
|
||||
# ./scripts/push_catalogs.sh --no-reload # push but don't call /reload
|
||||
#
|
||||
# Catalogs are read from DevOpsMCP repo (generated by sync_bicep_modules.py / sync_iac_module_sources.py)
|
||||
# and written to /opt/nomad/volumes/ilsp-data/ on autobox — the host volume iLSP mounts at /data.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DEVOPS_MCP_REPO="${DEVOPS_MCP_REPO:-$HOME/Projects/DevOpsMCP}"
|
||||
AUTOBOX="autobox.i80.dk"
|
||||
REMOTE_DIR="/opt/nomad/volumes/ilsp-data"
|
||||
HEALTH_URL="https://lsp.i80.dk/health"
|
||||
RELOAD_URL="https://lsp.i80.dk/reload"
|
||||
NO_RELOAD=false
|
||||
|
||||
for arg in "$@"; do
|
||||
[[ "$arg" == "--no-reload" ]] && NO_RELOAD=true
|
||||
done
|
||||
|
||||
# Catalog files to push
|
||||
BICEP_CATALOG="$DEVOPS_MCP_REPO/bicep_modules_catalog.json"
|
||||
IAC_CATALOG="$DEVOPS_MCP_REPO/iac_source_catalog.json"
|
||||
|
||||
echo "── iLSP catalog push ──────────────────────────────"
|
||||
|
||||
for f in "$BICEP_CATALOG" "$IAC_CATALOG"; do
|
||||
if [[ ! -f "$f" ]]; then
|
||||
echo " ✗ Not found: $f"
|
||||
echo " Run: python3 $DEVOPS_MCP_REPO/scripts/sync_bicep_modules.py"
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ $(basename "$f") ($(du -sh "$f" | cut -f1))"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo " → Copying to $AUTOBOX:$REMOTE_DIR/ …"
|
||||
ssh "$AUTOBOX" "mkdir -p $REMOTE_DIR"
|
||||
scp "$BICEP_CATALOG" "$IAC_CATALOG" "$AUTOBOX:$REMOTE_DIR/"
|
||||
echo " ✓ Upload done"
|
||||
|
||||
if [[ "$NO_RELOAD" == "true" ]]; then
|
||||
echo " (skipping /reload — restart iLSP manually to apply)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo " → Calling $RELOAD_URL …"
|
||||
if response=$(curl -sf -X POST "$RELOAD_URL" 2>/dev/null); then
|
||||
echo " ✓ $response"
|
||||
else
|
||||
echo " ✗ /reload failed (is lsp.i80.dk reachable? try: make health-prod)"
|
||||
echo " Catalogs are on disk — they'll be used on next restart."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo " Done. Bicep completions updated."
|
||||
Reference in New Issue
Block a user