#!/usr/bin/env bash
# Tail the logs of a specific service on the VPS.
# Usage:
#   ./logs.sh                    # interactive picker
#   ./logs.sh postgres           # tail postgres logs
#   ./logs.sh next               # tail Next.js
#   ./logs.sh kong               # tail Supabase API gateway
source "$(dirname "$0")/_lib.sh"

svc="${1:-}"
if [ -z "$svc" ]; then
  echo "Available services:"
  vps_ssh "cd ${VPS_DEPLOY_ROOT} && docker compose config --services 2>/dev/null || echo '(stack not yet deployed)'"
  echo ""
  read -rp "Service name: " svc
fi

vps_ssh "cd ${VPS_DEPLOY_ROOT} && docker compose logs --tail=200 -f ${svc}"
