Private
Public Access
install.sh: fail hard (or auto-install) when Redis isn't actually reachable
The old check only looked for redis-cli on PATH and printed a warning if missing — it never tested an actual connection, so a host with no Redis installed at all still sailed through the entire install looking successful. The real failure only showed up later as every feed stuck on "pending" forever, with the worker/beat units quietly retrying their connection in the background rather than surfacing anything to whoever ran the script. Actually connect to the REDIS_URL that will end up in .env; on Debian/Ubuntu with the default local address, install and start redis-server automatically; otherwise fail the install outright with a clear message instead of a warning that's easy to miss. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b0d62c91f8
commit
e1907ff587
1 file changed
+39
-3
+39
-3
@@ -63,9 +63,45 @@ if ! "$PYTHON_BIN" -c 'import ensurepip' >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v redis-cli >/dev/null 2>&1; then
|
# Celery (and therefore all feed fetching) is entirely dependent on Redis
|
||||||
echo "Warning: 'redis-cli' not found on PATH. Install it before going live" \
|
# being reachable — it fails silently from the installer's point of view
|
||||||
"(see docs/install.md's prerequisites section: apt install redis-server)." >&2
|
# (the worker/beat processes just retry forever in the background), so this
|
||||||
|
# has to be a hard failure here, not a warning that's easy to miss while
|
||||||
|
# every later step "succeeds" at installing an app that can never fetch a
|
||||||
|
# single feed. Check the actual REDIS_URL that will end up in .env (an
|
||||||
|
# explicit EVECTION_REDIS_URL override, if set — the default local Redis
|
||||||
|
# otherwise), not just whether some redis-cli happens to be on PATH.
|
||||||
|
REDIS_URL_TO_CHECK="${EVECTION_REDIS_URL:-redis://localhost:6379/0}"
|
||||||
|
check_redis() {
|
||||||
|
"$PYTHON_BIN" -c "
|
||||||
|
import sys, socket, urllib.parse
|
||||||
|
u = urllib.parse.urlparse('$REDIS_URL_TO_CHECK')
|
||||||
|
try:
|
||||||
|
with socket.create_connection((u.hostname or 'localhost', u.port or 6379), timeout=3):
|
||||||
|
pass
|
||||||
|
except OSError as e:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
"
|
||||||
|
}
|
||||||
|
REDIS_HOST="$("$PYTHON_BIN" -c "import urllib.parse; print(urllib.parse.urlparse('$REDIS_URL_TO_CHECK').hostname or 'localhost')")"
|
||||||
|
if ! check_redis; then
|
||||||
|
if [[ "$REDIS_HOST" =~ ^(localhost|127\.0\.0\.1|::1)$ ]] && command -v apt-get >/dev/null 2>&1; then
|
||||||
|
echo "==> Redis isn't reachable at $REDIS_URL_TO_CHECK — installing redis-server"
|
||||||
|
apt-get install -y redis-server
|
||||||
|
systemctl enable --now redis-server
|
||||||
|
if ! check_redis; then
|
||||||
|
echo "Redis still isn't reachable after installing redis-server —" \
|
||||||
|
"check: systemctl status redis-server" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Redis isn't reachable at $REDIS_URL_TO_CHECK. Evection's background" \
|
||||||
|
"feed-fetching depends on it entirely, so this has to be fixed before" \
|
||||||
|
"continuing — either start/install Redis there, or set" \
|
||||||
|
"EVECTION_REDIS_URL to point at wherever it actually runs." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 2. System user -----------------------------------------------------
|
# --- 2. System user -----------------------------------------------------
|
||||||
|
|||||||
Reference in new issue
Block a user