Private
Public Access
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1907ff587 | ||
|
|
b0d62c91f8 | ||
|
|
2068df471f |
No files matched your search
+45
-4
@@ -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 -----------------------------------------------------
|
||||||
@@ -201,7 +237,12 @@ for unit in evection-gunicorn evection-celery-worker evection-celery-beat; do
|
|||||||
"$APP_DIR/docs/deploy/${unit}.service" > "/etc/systemd/system/${unit}.service"
|
"$APP_DIR/docs/deploy/${unit}.service" > "/etc/systemd/system/${unit}.service"
|
||||||
done
|
done
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable --now evection-gunicorn evection-celery-worker evection-celery-beat
|
systemctl enable evection-gunicorn evection-celery-worker evection-celery-beat
|
||||||
|
# Not "enable --now": that only starts a service if it's stopped, so a
|
||||||
|
# re-run after a unit file changed (e.g. a new EVECTION_GUNICORN_BIND)
|
||||||
|
# would reload the daemon but leave the already-running process on its
|
||||||
|
# stale old ExecStart indefinitely. Always restart explicitly instead.
|
||||||
|
systemctl restart evection-gunicorn evection-celery-worker evection-celery-beat
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "==> Services installed. Checking status..."
|
echo "==> Services installed. Checking status..."
|
||||||
|
|||||||
+10
-1
@@ -112,7 +112,16 @@ HEALTH_PORT="${HEALTH_BIND##*:}"
|
|||||||
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
||||||
HEALTH_HOST="127.0.0.1"
|
HEALTH_HOST="127.0.0.1"
|
||||||
fi
|
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"
|
echo "Health check OK"
|
||||||
else
|
else
|
||||||
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
||||||
|
|||||||
Reference in new issue
Block a user