Files
romm/entrypoint.sh
Georges-Antoine Assi ea22b06502 fix(sync): export SYNC_BASE_PATH so the Python child inherits it
The shell fallback was assigned locally but never exported, so
sync_watcher.py and the Python config layer never saw the resolved
value. They happened to land on the same /var/lib/romm/sync default by
coincidence; export it so the shell and Python defaults stay linked
through a single source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 17:22:54 -04:00

97 lines
2.9 KiB
Bash

#!/bin/bash
set -e
echo "Starting entrypoint script..."
# Create symlinks for frontend
for subfolder in assets resources; do
if [[ -L /app/frontend/assets/romm/${subfolder} ]]; then
target=$(readlink "/app/frontend/assets/romm/${subfolder}")
# If the target is not the same as ${ROMM_BASE_PATH}/${subfolder}, recreate the symbolic link.
if [[ ${target} != "${ROMM_BASE_PATH}/${subfolder}" ]]; then
rm "/app/frontend/assets/romm/${subfolder}"
ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}"
fi
elif [[ ! -e /app/frontend/assets/romm/${subfolder} ]]; then
# Ensure parent directory exists before creating symbolic link
mkdir -p "/app/frontend/assets/romm"
ln -s "${ROMM_BASE_PATH}/${subfolder}" "/app/frontend/assets/romm/${subfolder}"
fi
done
# Define a signal handler to propagate termination signals
function handle_termination() {
echo "Terminating child processes..."
# Kill all background jobs
# trunk-ignore(shellcheck)
kill -TERM $(jobs -p) 2>/dev/null
}
# Trap SIGTERM and SIGINT signals
trap handle_termination SIGTERM SIGINT
# Set ROMM_AUTH_SECRET_KEY if not already set
if [[ -z ${ROMM_AUTH_SECRET_KEY} ]]; then
ROMM_AUTH_SECRET_KEY=$(python3 -c "import secrets; print(secrets.token_hex(32))")
export ROMM_AUTH_SECRET_KEY
fi
# Start all services in the background
echo "Starting backend..."
cd /app/backend
uv run python main.py &
echo "Starting RQ scheduler..."
RQ_REDIS_HOST=${REDIS_HOST:-127.0.0.1} \
RQ_REDIS_PORT=${REDIS_PORT:-6379} \
RQ_REDIS_USERNAME=${REDIS_USERNAME:-""} \
RQ_REDIS_PASSWORD=${REDIS_PASSWORD:-""} \
RQ_REDIS_DB=${REDIS_DB:-0} \
RQ_REDIS_SSL=${REDIS_SSL:-0} \
rqscheduler \
--path /app/backend \
--pid /tmp/rq_scheduler.pid &
echo "Starting RQ worker..."
# Build Redis URL properly
if [[ -n ${REDIS_PASSWORD-} ]]; then
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_USERNAME-}:${REDIS_PASSWORD}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
elif [[ -n ${REDIS_USERNAME-} ]]; then
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_USERNAME}@${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
else
REDIS_URL="redis${REDIS_SSL:+s}://${REDIS_HOST:-127.0.0.1}:${REDIS_PORT:-6379}/${REDIS_DB:-0}"
fi
# Set PYTHONPATH so RQ can find the tasks module
PYTHONPATH="/app/backend:${PYTHONPATH-}" rq worker \
--path /app/backend \
--pid /tmp/rq_worker.pid \
--url "${REDIS_URL}" \
--logging_level "${LOGLEVEL:-INFO}" \
high default low &
echo "Starting watcher..."
watchfiles \
--target-type command \
'uv run python watcher.py' \
/app/romm/library &
if [[ ${ENABLE_SYNC_FOLDER_WATCHER:-false} == "true" ]]; then
echo "Starting sync folder watcher..."
export SYNC_BASE_PATH="${SYNC_BASE_PATH:-/var/lib/romm/sync}"
mkdir -p "${SYNC_BASE_PATH}"
watchfiles \
--target-type command \
'uv run python sync_watcher.py' \
"${SYNC_BASE_PATH}" &
fi
# Start the frontend dev server
cd /app/frontend
npm run dev &
# Wait for all background processes
wait