File size: 3,432 Bytes
8c1b9fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656439d
 
 
 
 
8c1b9fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash
# Run Auralynq locally on a fixed IP + a custom port range (rootless Podman, no
# sudo). Usage:  scripts/run_local.sh {start|stop|restart|status|logs [svc]}
#
# Wired for `make start` / `make stop`. Browser-facing entry is the Caddy TLS
# proxy on PUBLIC_IP:HTTPS_PORT; every other service stays on host loopback.
#
# Port plan (2003 intentionally skipped — reserved by another app):
#   2002  HTTPS  (Caddy, the browser URL)
#   2004  web    (internal)
#   2005  api    (internal)
#   2006  qdrant http   (internal)
#   2007  qdrant grpc   (internal)
#   2008  mcp    (internal)
#   2009  phoenix UI    (internal)
#   2010  phoenix OTLP  (internal)
#
# These are exported into the environment; podman-compose gives them precedence
# over .env, so your secrets/.env are read for keys but never modified here.
set -euo pipefail
cd "$(dirname "$0")/.."

# ---- configuration (edit here) -----------------------------------------------
# Host you open in the browser; also the SAN baked into the self-signed cert.
# Defaults to localhost. For LAN/remote access export your machine's IP first:
#   AURALYNQ_HOST=yourIP ./scripts/run_local.sh
PUBLIC_IP="${AURALYNQ_HOST:-localhost}"
export AURALYNQ_CERT_HOST="${AURALYNQ_CERT_HOST:-$PUBLIC_IP}"   # browser host (cert SAN)

export AURALYNQ_HTTPS_PORT="2002"          # public — the URL you open
export AURALYNQ_WEB_PORT="2004"
export AURALYNQ_API_PORT="2005"
export AURALYNQ_QDRANT_HTTP_PORT="2006"
export AURALYNQ_QDRANT_GRPC_PORT="2007"
export AURALYNQ_MCP_PORT="2008"
export AURALYNQ_PHOENIX_PORT="2009"
export AURALYNQ_PHOENIX_OTLP_PORT="2010"

# Internal services stay on host loopback; only Caddy is published on the NIC.
export AURALYNQ_BIND_INTERNAL="127.0.0.1"
# Browser origin must be allowed by the API's CORS (matches the public URL).
export AURALYNQ_SERVE__CORS_ORIGINS="[\"https://${PUBLIC_IP}:${AURALYNQ_HTTPS_PORT}\"]"
# ------------------------------------------------------------------------------

COMPOSE="$(./scripts/check_container_runtime.sh)"
CF="compose.yml"
URL="https://${PUBLIC_IP}:${AURALYNQ_HTTPS_PORT}"

usage() { echo "usage: $0 {start|stop|restart|fresh|status|logs [service]}"; exit 1; }

start() {
  echo "→ starting Auralynq on ${URL} (ports 2002/2004-2010)…"
  ./scripts/stack_up.sh
  echo
  echo "✓ Open in your browser:  ${URL}"
  echo "  (accept the one-time self-signed cert warning)"
  echo "  Internal (loopback only): web:${AURALYNQ_WEB_PORT} api:${AURALYNQ_API_PORT} qdrant:${AURALYNQ_QDRANT_HTTP_PORT} mcp:${AURALYNQ_MCP_PORT} phoenix:${AURALYNQ_PHOENIX_PORT}"
}

stop() {
  echo "→ stopping Auralynq…"
  $COMPOSE -f "$CF" down
  echo "✓ stopped."
}

fresh() {
  echo "→ stopping Auralynq…"
  $COMPOSE -f "$CF" down
  echo "→ wiping corpus volumes (auralynq_auralynq-data, auralynq_auralynq-qdrant)…"
  podman volume rm -f auralynq_auralynq-data 2>/dev/null || true
  podman volume rm -f auralynq_auralynq-qdrant 2>/dev/null || true
  echo "✓ volumes cleared."
  start
}

status() {
  podman ps --filter "name=auralynq-" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || true
}

logs() {
  if [ "${1:-}" != "" ]; then
    podman logs -f "auralynq-${1}"
  else
    $COMPOSE -f "$CF" logs -f
  fi
}

case "${1:-}" in
  start)   start ;;
  stop)    stop ;;
  restart) stop; start ;;
  fresh)   fresh ;;
  status)  status ;;
  logs)    shift || true; logs "${1:-}" ;;
  *)       usage ;;
esac