mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-04-05 13:46:25 +02:00
Refactor entrypoint script for direct execution
Replaced sourcing of init scripts with direct bash execution. Removed application readiness check and cleanup logic.
This commit is contained in:
@@ -18,11 +18,8 @@ if [ -d /etc/cont-init.d ]; then
|
||||
for script in /etc/cont-init.d/*.sh; do
|
||||
[ -f "$script" ] || continue
|
||||
echo "[Maintainerr] Running init script: $script"
|
||||
# Source the script so it inherits bashio functions from bashio-standalone.
|
||||
# Using bash "$script" would spawn a new process without bashio:: functions,
|
||||
# causing "command not found" failures under set -e.
|
||||
# shellcheck disable=SC1090
|
||||
source "$script"
|
||||
# Use bash directly (no S6 with-contenv available)
|
||||
bash "$script"
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -61,32 +58,5 @@ export DATA_DIR
|
||||
|
||||
# ─── Start Maintainerr as unprivileged node user ─────────────────────────────
|
||||
echo "[Maintainerr] Starting application on port ${UI_PORT:-6246}..."
|
||||
gosu node /opt/app/start.sh &
|
||||
APP_PID=$!
|
||||
|
||||
cleanup() {
|
||||
if [ -n "${APP_PID:-}" ] && ps -p "$APP_PID" >/dev/null 2>&1; then
|
||||
kill "$APP_PID" 2>/dev/null || true
|
||||
wait "$APP_PID" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap 'cleanup' EXIT TERM INT
|
||||
|
||||
# ─── Wait for Maintainerr to become available, then start Nginx ──────────────
|
||||
echo "[Maintainerr] Waiting for application to be ready..."
|
||||
app_ready=0
|
||||
for _ in $(seq 1 900); do
|
||||
if curl -s -o /dev/null -f "http://127.0.0.1:${UI_PORT:-6246}" 2>/dev/null; then
|
||||
app_ready=1
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$app_ready" -ne 1 ]; then
|
||||
echo "[Maintainerr] ERROR: Application did not become ready within timeout. Aborting nginx startup."
|
||||
# cleanup trap will handle stopping APP_PID if still running
|
||||
exit 1
|
||||
fi
|
||||
echo "[Maintainerr] Starting Nginx..."
|
||||
exec nginx -c /etc/nginx/nginx.conf
|
||||
exec gosu node /opt/app/start.sh
|
||||
exec nginx
|
||||
|
||||
Reference in New Issue
Block a user