Update entrypoint.sh
Browse files- entrypoint.sh +37 -8
entrypoint.sh
CHANGED
|
@@ -1,20 +1,49 @@
|
|
| 1 |
#!/bin/sh
|
| 2 |
set -eu
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
echo "== DNS before =="
|
| 5 |
cat /etc/resolv.conf || true
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
fi
|
| 11 |
|
| 12 |
echo "== DNS after =="
|
| 13 |
cat /etc/resolv.conf || true
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
exec
|
|
|
|
| 1 |
#!/bin/sh
|
| 2 |
set -eu
|
| 3 |
|
| 4 |
+
# Never run with TLS verification disabled
|
| 5 |
+
if [ "${NODE_TLS_REJECT_UNAUTHORIZED:-}" = "0" ]; then
|
| 6 |
+
unset NODE_TLS_REJECT_UNAUTHORIZED
|
| 7 |
+
fi
|
| 8 |
+
|
| 9 |
+
# No proxy envs
|
| 10 |
+
unset HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXY || true
|
| 11 |
+
|
| 12 |
+
# Diagnostics tools
|
| 13 |
+
apk add --no-cache ca-certificates openssl curl bind-tools >/dev/null 2>&1 || true
|
| 14 |
+
update-ca-certificates >/dev/null 2>&1 || true
|
| 15 |
+
|
| 16 |
+
WORKER_HOST="fb-proxy.esafux.workers.dev"
|
| 17 |
+
|
| 18 |
+
echo "===== Application Startup at $(date -u '+%Y-%m-%d %H:%M:%S') ====="
|
| 19 |
+
echo "== NODE_OPTIONS =="; echo "${NODE_OPTIONS:-}" || true
|
| 20 |
+
|
| 21 |
echo "== DNS before =="
|
| 22 |
cat /etc/resolv.conf || true
|
| 23 |
|
| 24 |
+
resolve_host() {
|
| 25 |
+
getent hosts "$1" >/dev/null 2>&1
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
# If HF resolver can't resolve the Worker host, switch to public DNS
|
| 29 |
+
if ! resolve_host "$WORKER_HOST"; then
|
| 30 |
+
echo "== DNS fallback: cannot resolve $WORKER_HOST with HF DNS =="
|
| 31 |
+
if [ -w /etc/resolv.conf ]; then
|
| 32 |
+
cp /etc/resolv.conf /tmp/resolv.conf.bak 2>/dev/null || true
|
| 33 |
+
printf "nameserver 1.1.1.1\nnameserver 8.8.8.8\noptions timeout:2 attempts:2\n" > /etc/resolv.conf || true
|
| 34 |
+
fi
|
| 35 |
fi
|
| 36 |
|
| 37 |
echo "== DNS after =="
|
| 38 |
cat /etc/resolv.conf || true
|
| 39 |
|
| 40 |
+
echo "== DNS check (worker) =="
|
| 41 |
+
getent hosts "$WORKER_HOST" || true
|
| 42 |
+
dig +short A "$WORKER_HOST" || true
|
| 43 |
+
dig +short AAAA "$WORKER_HOST" || true
|
| 44 |
+
|
| 45 |
+
echo "== HTTPS probe (worker) =="
|
| 46 |
+
curl -sS -o /dev/null -w "worker:%{http_code}\n" "https://$WORKER_HOST/fb/v23.0/me?fields=id,name" || true
|
| 47 |
|
| 48 |
+
echo "Initializing n8n process"
|
| 49 |
+
exec su-exec node "$@"
|