From 49513cc0813eb7ca41b728eb42c9bdde22e3160a Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Thu, 26 Feb 2026 13:57:12 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20port=20drift=20on=20restart=20=E2=80=94?= =?UTF-8?q?=20down=20before=20preflight,=20read=20port=20from=20.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- Makefile | 6 ++++-- manage.sh | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8fc0936..5767b9e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/manage.sh b/manage.sh index 1fc484b..57665a0 100755 --- a/manage.sh +++ b/manage.sh @@ -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