fix: port drift on restart — down before preflight, read port from .env

Makefile restart target now runs compose down before preflight so ports
are free when preflight assigns them; previously preflight ran first while
the old container still held 8502, causing it to bump to 8503.

manage.sh start/restart/open now read STREAMLIT_PORT from .env instead
of re-running preflight after startup (which would see the live container
and bump the reported port again).
This commit is contained in:
pyr0ball 2026-02-26 13:57:12 -08:00
parent bf33a584b4
commit 49513cc081
2 changed files with 7 additions and 5 deletions

View file

@ -47,8 +47,10 @@ start: preflight ## Preflight check then start Peregrine (PROFILE=remote|cpu|si
stop: ## Stop all Peregrine services
$(COMPOSE) down
restart: preflight ## Preflight check then restart all services
$(COMPOSE) down && $(COMPOSE) $(COMPOSE_FILES) --profile $(PROFILE) up -d
restart: ## Stop services, re-run preflight (ports now free), then start
$(COMPOSE) down
@$(PYTHON) scripts/preflight.py
$(COMPOSE) $(COMPOSE_FILES) --profile $(PROFILE) up -d
logs: ## Tail app logs
$(COMPOSE) logs -f app

View file

@ -82,7 +82,7 @@ case "$CMD" in
start)
info "Starting Peregrine (PROFILE=${PROFILE})..."
make start PROFILE="$PROFILE"
PORT="$(python3 scripts/preflight.py --service streamlit 2>/dev/null || echo 8501)"
PORT="$(grep -m1 '^STREAMLIT_PORT=' .env 2>/dev/null | cut -d= -f2 || echo 8501)"
success "Peregrine is up → http://localhost:${PORT}"
;;
@ -95,7 +95,7 @@ case "$CMD" in
restart)
info "Restarting (PROFILE=${PROFILE})..."
make restart PROFILE="$PROFILE"
PORT="$(python3 scripts/preflight.py --service streamlit 2>/dev/null || echo 8501)"
PORT="$(grep -m1 '^STREAMLIT_PORT=' .env 2>/dev/null | cut -d= -f2 || echo 8501)"
success "Peregrine restarted → http://localhost:${PORT}"
;;
@ -148,7 +148,7 @@ case "$CMD" in
;;
open)
PORT="$(python3 scripts/preflight.py --service streamlit 2>/dev/null || echo 8501)"
PORT="$(grep -m1 '^STREAMLIT_PORT=' .env 2>/dev/null | cut -d= -f2 || echo 8501)"
URL="http://localhost:${PORT}"
info "Opening ${URL}"
if command -v xdg-open &>/dev/null; then