fix(watcher): skip opentelemetry-instrument when OTEL is disabled

When OTEL_SDK_DISABLED=true (set automatically when no OTEL_ env vars
are present), the opentelemetry-instrument wrapper does not properly
pass through the WATCHFILES_CHANGES environment variable to watcher.py.

This causes the filesystem watcher to silently fail - watchfiles detects
changes but watcher.py receives an empty WATCHFILES_CHANGES and exits
immediately without scheduling any rescans.

The fix skips the opentelemetry-instrument wrapper when OTEL is disabled,
allowing watchfiles to pass WATCHFILES_CHANGES directly to watcher.py.

Fixes automatic rescan on filesystem change for users who don't configure
OpenTelemetry (the majority of self-hosted deployments).
This commit is contained in:
Christian Rehm
2026-01-30 23:18:49 +00:00
parent 983da2c77d
commit 91ee163585

View File

@@ -219,10 +219,19 @@ start_bin_rq_worker() {
start_bin_watcher() {
info_log "Starting watcher"
watchfiles \
--target-type command \
"opentelemetry-instrument --service_name '${OTEL_SERVICE_NAME_PREFIX-}watcher' python3 watcher.py" \
/romm/library &
if [[ ${OTEL_SDK_DISABLED:-false} == "true" ]]; then
# Skip opentelemetry-instrument when OTEL is disabled to ensure
# WATCHFILES_CHANGES env var is properly passed to watcher.py
watchfiles \
--target-type command \
"python3 watcher.py" \
/romm/library &
else
watchfiles \
--target-type command \
"opentelemetry-instrument --service_name '${OTEL_SERVICE_NAME_PREFIX-}watcher' python3 watcher.py" \
/romm/library &
fi
WATCHER_PID=$!
echo "${WATCHER_PID}" >/tmp/watcher.pid
}