Private
Public Access
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1907ff587 | ||
|
|
b0d62c91f8 |
No files matched your search
+39
-3
@@ -63,9 +63,45 @@ if ! "$PYTHON_BIN" -c 'import ensurepip' >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v redis-cli >/dev/null 2>&1; then
|
||||
echo "Warning: 'redis-cli' not found on PATH. Install it before going live" \
|
||||
"(see docs/install.md's prerequisites section: apt install redis-server)." >&2
|
||||
# Celery (and therefore all feed fetching) is entirely dependent on Redis
|
||||
# being reachable — it fails silently from the installer's point of view
|
||||
# (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
|
||||
|
||||
# --- 2. System user -----------------------------------------------------
|
||||
|
||||
+10
-1
@@ -112,7 +112,16 @@ HEALTH_PORT="${HEALTH_BIND##*:}"
|
||||
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
||||
HEALTH_HOST="127.0.0.1"
|
||||
fi
|
||||
if curl -sf "http://$HEALTH_HOST:$HEALTH_PORT/health/" >/dev/null; then
|
||||
# Use the venv's own Python rather than curl — curl isn't guaranteed to be
|
||||
# installed on a minimal host, but the venv obviously already is.
|
||||
if "$VENV_DIR/bin/python" -c "
|
||||
import sys, urllib.request
|
||||
try:
|
||||
urllib.request.urlopen('http://$HEALTH_HOST:$HEALTH_PORT/health/', timeout=5)
|
||||
except Exception as e:
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
"; then
|
||||
echo "Health check OK"
|
||||
else
|
||||
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
||||
|
||||
Reference in new issue
Block a user