waxwing/manage.sh
pyr0ball c81fa3a93a feat: add Plex integration, update knowledge API and config
- Add app/api/endpoints/plex.py with Plex webhook receiver (fail-closed on missing secret)
- Add app/services/plex/ with Plex API client and gardening content filter
- Wire plex router into routes.py at /plex prefix
- Add Plex + cf-video config vars to app/core/config.py and .env.example
- Rename /knowledge/ingest endpoint to /knowledge/glean (pipeline verb alignment)
- Update tests to use /knowledge/glean endpoint
- Add python-multipart to environment.yml for form/webhook body parsing
- Add dev/dev-stop/dev-logs commands to manage.sh (hot-reload without Docker)
- Fix frontend/tsconfig.node.json to extend tsconfig.json (not tsconfig.node.json)
- Add .dev-pids/ to .gitignore
- Add frontend/package-lock.json
2026-07-11 22:38:37 -07:00

117 lines
3.6 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
SERVICE=waxwing
WEB_PORT=8521
API_PORT=8522
COMPOSE_FILE="compose.yml"
OVERRIDE_FLAG=""
[[ -f "compose.override.yml" ]] && OVERRIDE_FLAG="-f compose.override.yml"
DEV_DIR=".dev-pids"
DEV_API_PID="$DEV_DIR/api.pid"
DEV_WEB_PID="$DEV_DIR/web.pid"
DEV_API_LOG="$DEV_DIR/api.log"
DEV_WEB_LOG="$DEV_DIR/web.log"
usage() {
echo "Usage: $0 {start|stop|restart|status|logs|open|build|test|update|dev|dev-stop|dev-logs}"
echo ""
echo "Docker commands:"
echo " start Build (if needed) and start all services"
echo " stop Stop and remove containers"
echo " restart Stop then start"
echo " status Show running containers"
echo " logs [svc] Follow logs (api | web — defaults to all)"
echo " open Open web UI in browser"
echo " build Rebuild Docker images without cache"
echo " test Run pytest test suite"
echo " update git pull + rebuild + restart"
echo ""
echo "Dev server commands (no Docker):"
echo " dev Start FastAPI + Vite dev server (hot reload)"
echo " dev-stop Stop dev servers"
echo " dev-logs Tail dev server logs"
exit 1
}
cmd="${1:-help}"
shift || true
case "$cmd" in
start)
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build
echo "Waxwing running → http://localhost:${WEB_PORT}"
;;
stop)
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down
;;
restart)
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build
echo "Waxwing running → http://localhost:${WEB_PORT}"
;;
status)
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG ps
;;
logs)
svc="${1:-}"
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG logs -f ${svc}
;;
open)
xdg-open "http://localhost:${WEB_PORT}" 2>/dev/null \
|| open "http://localhost:${WEB_PORT}" 2>/dev/null \
|| echo "Open http://localhost:${WEB_PORT} in your browser"
;;
build)
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG build --no-cache
;;
test)
conda run -n cf python -m pytest tests/ -v
;;
update)
git pull
docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build
echo "Waxwing updated → http://localhost:${WEB_PORT}"
;;
dev)
mkdir -p "$DEV_DIR"
if [[ -f "$DEV_API_PID" ]] && kill -0 "$(cat "$DEV_API_PID")" 2>/dev/null; then
echo "Dev API already running (PID $(cat "$DEV_API_PID"))"
else
conda run --no-capture-output -n cf uvicorn app.main:app \
--host 0.0.0.0 --port "$API_PORT" --reload \
> "$DEV_API_LOG" 2>&1 &
echo $! > "$DEV_API_PID"
echo "API started (PID $!) → http://localhost:${API_PORT}"
fi
if [[ -f "$DEV_WEB_PID" ]] && kill -0 "$(cat "$DEV_WEB_PID")" 2>/dev/null; then
echo "Dev web already running (PID $(cat "$DEV_WEB_PID"))"
else
(cd frontend && npm run dev -- --host 0.0.0.0 --port "$WEB_PORT" \
> "../$DEV_WEB_LOG" 2>&1) &
echo $! > "$DEV_WEB_PID"
echo "Web started (PID $!) → http://localhost:${WEB_PORT}"
fi
echo "Logs: $DEV_API_LOG $DEV_WEB_LOG"
;;
dev-stop)
for pidfile in "$DEV_API_PID" "$DEV_WEB_PID"; do
if [[ -f "$pidfile" ]]; then
pid=$(cat "$pidfile")
if kill -0 "$pid" 2>/dev/null; then
kill "$pid" && echo "Stopped PID $pid"
fi
rm -f "$pidfile"
fi
done
echo "Dev servers stopped."
;;
dev-logs)
tail -f "$DEV_API_LOG" "$DEV_WEB_LOG"
;;
*)
usage
;;
esac