From 7e5e5b4b8d51ead1c5b5232ec423346585212612 Mon Sep 17 00:00:00 2001 From: ncd Date: Fri, 5 Dec 2025 23:06:44 +0100 Subject: [PATCH] Logging enabled, telemetry disabled, waits for Postgres --- bin/create_pod_langflow.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/create_pod_langflow.sh b/bin/create_pod_langflow.sh index d454978..c394f59 100755 --- a/bin/create_pod_langflow.sh +++ b/bin/create_pod_langflow.sh @@ -46,12 +46,34 @@ podman run -d --name "$POSTGRES_CTR_NAME" --pod "$POD_NAME" \ "$POSTGRES_IMAGE" echo "Container '$POSTGRES_CTR_NAME' started (rc=$?)" +# Wait for Postgres to be ready before starting Langflow +# This avoids initial connection-refused errors in Langflow logs +# and ensures DB-backed features (like Global Variables) are +# available as soon as Langflow starts. +echo "Waiting for Postgres to be ready..." +for attempt in $(seq 1 30); do + if podman exec "$POSTGRES_CTR_NAME" pg_isready -U langflow -d langflow >/dev/null 2>&1; then + echo "Postgres is ready." + break + fi + sleep 2 + if [ "$attempt" -eq 30 ]; then + echo "ERROR: Postgres did not become ready in time." >&2 + exit 1 + fi +done + # Langflow container # In a Podman pod all containers share the same network namespace, # so Postgres is reachable via localhost instead of the container name. podman run -d --name "$LANGFLOW_CTR_NAME" --pod "$POD_NAME" \ -e LANGFLOW_DATABASE_URL=postgresql://langflow:langflow@localhost:5432/langflow \ -e LANGFLOW_CONFIG_DIR=/app/langflow \ + -e LANGFLOW_LOG_FILE=/app/langflow/langflow.log \ + -e LANGFLOW_LOG_ENV=default \ + -e LANGFLOW_PRETTY_LOGS=true \ + -e LANGFLOW_LOG_LEVEL=INFO \ + -e DO_NOT_TRACK=True \ -v "$LANGFLOW_DATA_DIR:/app/langflow:Z" \ "$LANGFLOW_IMAGE" echo "Container '$LANGFLOW_CTR_NAME' started (rc=$?)" @@ -62,7 +84,7 @@ podman generate systemd --name --new --files "$POD_NAME" echo "Generated systemd service files (rc=$?)" # Stop & remove live pod and containers -podman pod stop --ignore --time 30 "$POD_NAME" +podman pod stop --ignore --time 15 "$POD_NAME" podman pod rm -f --ignore "$POD_NAME" if podman pod exists "$POD_NAME"; then echo "ERROR: Pod $POD_NAME still exists." >&2