Files
hassio-addons/birdnet-pipy/rootfs/etc/services.d/nginx/run
Yudong Sun cae9984aaa birdnet-pipy: wait for upstream API before starting nginx
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) <noreply@anthropic.com>
2026-05-02 23:50:20 -04:00

15 lines
592 B
Plaintext

#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -euo pipefail
# 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
bashio::log.info "Starting NGinx..."
exec nginx