Compare commits

...

10 Commits

Author SHA1 Message Date
Alexandre
9151d3bc8a Clean logs
birdnet-go: quiet startup logs (chmod, JACK, OSS, dsnoop)
2026-05-27 10:29:18 +02:00
Alexandre
0248c95e59 Merge branch 'master' into claude/birdnet-go-startup-errors-ttace 2026-05-27 10:28:12 +02:00
Claude
78b47f5355 birdnet-go: ship ALSA overrides at /root/.asoundrc
/etc/asound.conf is read-only in the addon environment, so both the
shipped overrides and the user-supplied override are now written to
/root/.asoundrc (the app runs as root with HOME=/root). ALSA loads
~/.asoundrc as an additive layer on top of the system config, so the
override behavior is unchanged.
2026-05-27 08:26:36 +00:00
Alexandre
8f423ad2f4 Merge pull request #2737 from alexbelgium/copilot/birdnet-go-fix-log-storage nobuild
feat(birdnet-go): add log rotation options to prevent unbounded log growth
2026-05-27 10:21:58 +02:00
Alexandre
733134ed5d Update CHANGELOG.md 2026-05-27 10:15:13 +02:00
Alexandre
d6de19315d Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-05-27 07:27:14 +02:00
copilot-swe-agent[bot]
71bb8b5130 feat(birdnet-go): add LOG_MAX_SIZE_MB and LOG_MAX_AGE_DAYS options to manage log storage
Add addon options to control birdnet-go log file rotation:
- LOG_MAX_SIZE_MB (default: 50): maximum size per log file before rotation
- LOG_MAX_AGE_DAYS (default: 7): maximum days to retain old log files

On startup, the addon:
1. Configures birdnet-go's logging.file_output settings in config.yaml
2. Sets max_rotated_files to 3 and enables compression
3. Trims existing log files exceeding the configured age

Fixes #1922
2026-05-26 19:47:38 +00:00
Claude
4975eca7c2 birdnet-go: allow user-supplied /config/asound.conf override
Advanced users who legitimately need JACK, a custom dsnoop chain, or any
other ALSA setup can drop their own asound.conf into the addon config
folder. The cont-init script copies it over /etc/asound.conf before
launching the app, replacing the addon-shipped defaults.
2026-05-26 19:47:05 +00:00
copilot-swe-agent[bot]
e09e2afb2c Initial plan 2026-05-26 19:45:00 +00:00
Claude
05cbe751d5 birdnet-go: suppress noisy startup errors
- Patch upstream entrypoint via sed so chmod on the read-only /dev/snd
  mount no longer prints "Read-only file system" lines.
- Add /etc/asound.conf overriding the JACK, OSS, dsp, and dsnoop PCM
  plugins to type "null" with hint.show off. This hides them from
  snd_device_name_hint(), so miniaudio's device enumeration no longer
  probes them at launch and the corresponding libjack/pcm_oss/pcm_dsnoop
  errors disappear.
2026-05-26 16:23:20 +00:00
6 changed files with 91 additions and 1 deletions

View File

@@ -1,5 +1,12 @@
## nightly-20260525-2 (26-05-2026)
- Suppress noisy startup logs: silence `chmod /dev/snd` errors on the read-only HA mount, and hide unavailable ALSA plugins (JACK, OSS, dsnoop) from device enumeration so libjack and pcm_oss/dsnoop probes no longer print at launch. ALSA overrides are written to `/root/.asoundrc` (since `/etc/asound.conf` is read-only in this environment).
- Allow advanced users to override the ALSA config by dropping a custom `asound.conf` into the addon config folder.
- Add LOG_MAX_SIZE_MB and LOG_MAX_AGE_DAYS addon options to manage log storage size
- Automatically trim log files exceeding configured age on startup
## nightly-20260525 (26-05-2026)
- Minor bugs fixed
## nightly-20260511-414-2 (22-05-2026)
- Minor bugs fixed

View File

@@ -36,6 +36,13 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
COPY rootfs/ /
RUN find . -type f \( -name "*.sh" -o -name "run" -o -name "finish" \) -print -exec chmod +x {} \;
# Silence "chmod: Read-only file system" noise from upstream entrypoint:
# Home Assistant mounts /dev/snd read-only, so the chmod is a no-op and the
# stderr output is just noise. The "|| true" already absorbs the exit code.
RUN if [ -f /usr/bin/entrypoint.sh ]; then \
sed -i 's#chmod -R a+rw /dev/snd || true#chmod -R a+rw /dev/snd 2>/dev/null || true#' /usr/bin/entrypoint.sh; \
fi
# Uses /bin for compatibility purposes
# hadolint ignore=DL4005
RUN if [ ! -f /bin/sh ] && [ -f /usr/bin/sh ]; then ln -s /usr/bin/sh /bin/sh; fi && \

View File

@@ -86,6 +86,8 @@ name: Birdnet-go
options:
env_vars: []
BIRDSONGS_FOLDER: /config/clips
LOG_MAX_SIZE_MB: 50
LOG_MAX_AGE_DAYS: 7
homeassistant_microphone: false
panel_admin: false
panel_icon: mdi:bird
@@ -104,6 +106,8 @@ schema:
- name: match(^[A-Za-z0-9_]+$)
value: str?
BIRDSONGS_FOLDER: str?
LOG_MAX_SIZE_MB: int(1,1000)?
LOG_MAX_AGE_DAYS: int(1,365)?
TZ: str?
cifsdomain: str?
cifspassword: str?
@@ -118,4 +122,4 @@ slug: birdnet-go
udev: true
url: https://github.com/alexbelgium/hassio-addons/tree/master/birdnet-go
usb: true
version: "nightly-20260525"
version: "nightly-20260525-2"

View File

@@ -100,3 +100,26 @@ bashio::log.info "Correcting configuration for defaults"
# Update database location in config files
yq -i -y ".output.sqlite.path = \"/config/birdnet.db\"" "$CONFIG_LOCATION"
bashio::log.info "... database is located in /config/birdnet.db"
####################
# Log Management
####################
LOG_MAX_SIZE_MB="$(bashio::config "LOG_MAX_SIZE_MB")"
LOG_MAX_SIZE_MB="${LOG_MAX_SIZE_MB:-50}"
LOG_MAX_AGE_DAYS="$(bashio::config "LOG_MAX_AGE_DAYS")"
LOG_MAX_AGE_DAYS="${LOG_MAX_AGE_DAYS:-7}"
bashio::log.info "Configuring log rotation: max ${LOG_MAX_SIZE_MB}MB per file, max ${LOG_MAX_AGE_DAYS} days retention"
# Configure log rotation in birdnet-go config
yq -i -y ".logging.file_output.max_size = ${LOG_MAX_SIZE_MB}" "$CONFIG_LOCATION"
yq -i -y ".logging.file_output.max_age = ${LOG_MAX_AGE_DAYS}" "$CONFIG_LOCATION"
yq -i -y ".logging.file_output.max_rotated_files = 3" "$CONFIG_LOCATION"
yq -i -y ".logging.file_output.compress = true" "$CONFIG_LOCATION"
# Trim existing log files that exceed the configured max age
LOG_DIR="/config/logs"
if [ -d "$LOG_DIR" ]; then
bashio::log.info "Trimming log files older than ${LOG_MAX_AGE_DAYS} days in ${LOG_DIR}"
find "$LOG_DIR" -type f -name "*.log*" -mtime +"$LOG_MAX_AGE_DAYS" -delete 2>/dev/null || true
fi

View File

@@ -8,6 +8,20 @@ set -e
echo " "
# Allow advanced users to supply their own ALSA config (e.g. to enable JACK
# or a custom dsnoop chain) by dropping asound.conf into the addon config
# folder. Written to /root/.asoundrc because /etc/asound.conf is read-only.
if [ -f /config/asound.conf ]; then
if [ -r /config/asound.conf ]; then
bashio::log.info "Using user-provided /config/asound.conf, overriding addon defaults"
if ! cp /config/asound.conf /root/.asoundrc; then
bashio::log.warning "Failed to copy /config/asound.conf; continuing with bundled /root/.asoundrc defaults"
fi
else
bashio::log.warning "/config/asound.conf exists but is not readable; continuing with bundled /root/.asoundrc defaults"
fi
fi
# Check if alsa_card is provided
CONFIG_LOCATION="/config/config.yaml"
if bashio::config.true "homeassistant_microphone"; then

View File

@@ -0,0 +1,35 @@
# Home Assistant addon: birdnet-go
#
# Shipped at /root/.asoundrc because /etc/asound.conf is read-only in this
# environment. ALSA loads ~/.asoundrc as an additive layer on top of the
# system config, so the overrides below take effect for the birdnet-go process
# (which runs as root, HOME=/root).
#
# Replace ALSA PCM plugins whose backends are not available in the addon
# container (JACK server, OSS /dev/dsp) with type "null" and hide them from
# snd_device_name_hint(). Without this, miniaudio's capture-device enumeration
# probes every PCM hint at startup, triggering noisy errors like:
# - "Cannot connect to server socket" / "jack server is not running" (libjack)
# - "ALSA lib pcm_oss.c: Cannot open device /dev/dsp"
# - "ALSA lib pcm_dsnoop.c: unable to open slave"
# BirdNET-Go itself never opens these PCMs; only the enumeration probe does.
pcm.!jack {
type null
hint.show off
}
pcm.!oss {
type null
hint.show off
}
pcm.!dsp {
type null
hint.show off
}
pcm.!dsnoop {
type null
hint.show off
}