From cae9984aaa6e2219500986eee060ce79be5a35d1 Mon Sep 17 00:00:00 2001 From: Yudong Sun Date: Sat, 2 May 2026 23:50:20 -0400 Subject: [PATCH] birdnet-pipy: wait for upstream API before starting nginx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the 0.6.6-3 sleep+ingress-file-loop in services.d/nginx/run with bashio::net.wait_for on 127.0.0.1:5002 (core.api). Under s6-overlay all services.d/* services start concurrently, so nginx could accept requests before the API had bound its port — proxy paths (/api/, /socket.io/, /internal/auth) would 502, and that 502 could be cached by an upstream service worker / edge cache (e.g. Cloudflare- fronted HA), leaving the UI blank. Matches the sister-addon pattern (bazarr, jellyfin, radarr). Also switches to `exec nginx` for proper s6 supervision of the nginx PID. Co-Authored-By: Claude Opus 4.7 (1M context) --- birdnet-pipy/CHANGELOG.md | 2 ++ birdnet-pipy/config.yaml | 2 +- birdnet-pipy/rootfs/etc/services.d/nginx/run | 18 +++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/birdnet-pipy/CHANGELOG.md b/birdnet-pipy/CHANGELOG.md index 220747b34..5f64f3a83 100644 --- a/birdnet-pipy/CHANGELOG.md +++ b/birdnet-pipy/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.6.6-4 (2026-05-02) +- Fix nginx startup: wait for the upstream API on `127.0.0.1:5002` before starting nginx, instead of the prior `sleep 5` workaround. Under s6-overlay all `services.d/*` services start concurrently, so nginx could begin accepting requests before `core.api` had bound its port — `/api/`, `/socket.io/`, and `/internal/auth` would then return 502, and that 502 could be cached by an upstream service worker / edge cache (e.g. behind Cloudflare-fronted HA), leaving the UI stuck blank. Uses `bashio::net.wait_for` to match the pattern in sister addons (`bazarr`, `jellyfin`, `radarr`). ## 0.6.6-3 (23-04-2026) - Minor bugs fixed ## 0.6.6-2 (23-04-2026) diff --git a/birdnet-pipy/config.yaml b/birdnet-pipy/config.yaml index 59645327b..083c7751c 100644 --- a/birdnet-pipy/config.yaml +++ b/birdnet-pipy/config.yaml @@ -96,4 +96,4 @@ schema: ssl: bool? slug: birdnet-pipy url: https://github.com/alexbelgium/hassio-addons/tree/master/birdnet-pipy -version: "0.6.6-3" +version: "0.6.6-4" diff --git a/birdnet-pipy/rootfs/etc/services.d/nginx/run b/birdnet-pipy/rootfs/etc/services.d/nginx/run index a91a460e1..3325a35c0 100644 --- a/birdnet-pipy/rootfs/etc/services.d/nginx/run +++ b/birdnet-pipy/rootfs/etc/services.d/nginx/run @@ -2,13 +2,13 @@ # shellcheck shell=bash set -euo pipefail -# Wait for ingress configuration to be generated -while [ ! -f /etc/nginx/servers/ingress.conf ]; do - bashio::log.info "Waiting for /etc/nginx/servers/ingress.conf..." - sleep 1 -done +# Wait for the upstream API service (Python core.api) to bind 127.0.0.1:5002 +# before starting nginx, so nginx never serves a 502 for the API/auth/socket +# paths during boot. A boot-time 502 can be cached by an upstream cache layer +# (HA's own PWA service worker, a Cloudflare edge worker, etc.), leaving the +# UI in a stuck blank state until the cache is purged. +bashio::log.info "Waiting for upstream API on 127.0.0.1:5002..." +bashio::net.wait_for 5002 127.0.0.1 900 -# Wait to be sure the script fully executed -sleep 5 - -nginx +bashio::log.info "Starting NGinx..." +exec nginx