- start.sh: --max-old-space-size=384 so V8 GCs aggressively instead of deferring until the ~1.4 GB default ceiling - HLS proxy: destroy the upstream mediamtx request when the client closes the connection; add proxyRes error handler to avoid uncaught emissions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.1 KiB
Bash
40 lines
1.1 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
HWACCEL="${HWACCEL:-none}"
|
|
|
|
# Auto-detect the best available hardware accelerator by checking device nodes.
|
|
# /dev/nvidia0 → NVENC (NVIDIA, requires NVIDIA Container Toolkit + deploy config)
|
|
# /dev/dri/renderD128 → VAAPI (Intel/AMD, requires /dev/dri device passthrough)
|
|
# falls back to software (mediamtx built-in recorder, no FFmpeg)
|
|
detect_hwaccel() {
|
|
if [ -e /dev/nvidia0 ] && [ -e /dev/nvidiactl ]; then
|
|
echo "nvenc"
|
|
elif [ -e /dev/dri/renderD128 ]; then
|
|
echo "vaapi"
|
|
else
|
|
echo "none"
|
|
fi
|
|
}
|
|
|
|
if [ "$HWACCEL" = "auto" ]; then
|
|
HWACCEL=$(detect_hwaccel)
|
|
echo "[start] auto-detected hardware acceleration: $HWACCEL"
|
|
fi
|
|
|
|
if [ "$HWACCEL" = "none" ]; then
|
|
CONFIG=/app/mediamtx.yml
|
|
else
|
|
CONFIG=/app/mediamtx-hwaccel.yml
|
|
echo "[start] hardware acceleration: $HWACCEL"
|
|
fi
|
|
|
|
# Export so on-ready-hw.sh inherits the resolved value
|
|
export HWACCEL
|
|
|
|
# Start mediamtx in the background; Express handles auth and serves HLS.
|
|
mediamtx "$CONFIG" &
|
|
|
|
# Exec Node.js as the foreground process so Docker tracks it for health/stop.
|
|
exec node --max-old-space-size=384 dist/index.js
|