← back to Dw Photo Capture
visual-search/deploy-kamatera/setup.sh
22 lines
#!/usr/bin/env bash
# Path (a): run visual-search self-contained on Kamatera, reading the LOCAL dw_unified.
# Idempotent. Serves localhost:9914 so pairs-well points VISUAL_SEARCH_URL at 127.0.0.1.
set -euo pipefail
HERE="$(cd "$(dirname "$0")/.." && pwd)" # .../visual-search
VE="$HERE/.venv-lite"
# dw_unified connection = the same DB pairs-well already uses on this box.
DBURL="$(grep -E '^DATABASE_URL=' /root/Projects/dw-pairs-well/.env | head -1 | cut -d= -f2-)"
[ -n "$DBURL" ] || { echo "FATAL: could not read DATABASE_URL from pairs-well .env"; exit 1; }
[ -d "$VE" ] || python3 -m venv "$VE"
"$VE/bin/pip" -q install --upgrade pip
"$VE/bin/pip" -q install -r "$HERE/deploy-kamatera/requirements-lite.txt"
# (re)start under pm2 as 'visual-search', bound to localhost only.
pm2 delete visual-search 2>/dev/null || true
DW_UNIFIED_DB="$DBURL" VS_PORT=9914 VS_HOST=127.0.0.1 \
pm2 start "$VE/bin/python" --name visual-search --cwd "$HERE" -- "$HERE/search_service.py"
pm2 save
sleep 20
echo "--- health ---"; curl -s http://127.0.0.1:9914/health; echo