Private
Public Access
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2ee793cf8 | ||
|
|
b7d9ee672c | ||
|
|
d7b433e580 | ||
|
|
b52ba2be8a | ||
|
|
56eb2bc498 | ||
|
|
9d91da6fc6 | ||
|
|
c316f411f8 | ||
|
|
e1907ff587 | ||
|
|
b0d62c91f8 | ||
|
|
2068df471f |
No files matched your search
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.2.18 on 2026-10-31 18:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("accounts", "0001_initial"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="SetupLock",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.PositiveSmallIntegerField(default=1, primary_key=True, serialize=False),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -5,3 +5,15 @@ from django.db import models
|
||||
class User(AbstractUser):
|
||||
timezone = models.CharField(max_length=64, default="UTC")
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
|
||||
class SetupLock(models.Model):
|
||||
"""Singleton row that gates first-run setup against a race between
|
||||
concurrent requests. The setup view always tries to INSERT the row
|
||||
with pk=1 in the same transaction as creating the first admin user:
|
||||
the database's primary-key uniqueness makes exactly one of those
|
||||
INSERTs win even under concurrent requests, so only one admin account
|
||||
can ever be created this way, instead of the User.objects.exists()
|
||||
check alone (which has a window between the check and the save)."""
|
||||
|
||||
id = models.PositiveSmallIntegerField(primary_key=True, default=1)
|
||||
+23
-1
@@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
from django.urls import reverse
|
||||
|
||||
from .models import User
|
||||
from .models import SetupLock, User
|
||||
|
||||
# SetupWizardMiddleware's cache is reset around every test by the autouse
|
||||
# fixture in the top-level conftest.py, not just here.
|
||||
@@ -43,6 +43,28 @@ def test_setup_creates_admin_and_logs_in(client):
|
||||
assert stream_response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setup_refuses_a_second_concurrent_submission(client):
|
||||
# Simulates two requests racing the setup form: the first claims the
|
||||
# SetupLock row directly (standing in for a request that's already
|
||||
# past the User.objects.exists() check), so a second submission's
|
||||
# INSERT must lose instead of also creating an admin account.
|
||||
SetupLock.objects.create()
|
||||
|
||||
response = client.post(
|
||||
reverse("accounts:setup"),
|
||||
{
|
||||
"username": "raced",
|
||||
"email": "raced@example.com",
|
||||
"password": "correct-horse-battery",
|
||||
"password_confirm": "correct-horse-battery",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 302
|
||||
assert response.url == reverse("accounts:login")
|
||||
assert not User.objects.filter(username="raced").exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_setup_is_unreachable_once_a_user_exists(client):
|
||||
User.objects.create_user("existing", password="irrelevant")
|
||||
|
||||
+17
-6
@@ -1,11 +1,12 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.decorators import user_passes_test
|
||||
from django.db import IntegrityError, transaction
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from .forms import CreateUserForm, SetupForm
|
||||
from .middleware import SetupWizardMiddleware
|
||||
from .models import User
|
||||
from .models import SetupLock, User
|
||||
|
||||
is_admin = user_passes_test(lambda u: u.is_authenticated and u.is_staff)
|
||||
|
||||
@@ -16,11 +17,21 @@ def setup(request):
|
||||
|
||||
form = SetupForm(request.POST or None)
|
||||
if request.method == "POST" and form.is_valid():
|
||||
user = form.save(commit=False)
|
||||
user.set_password(form.cleaned_data["password"])
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
user.save()
|
||||
try:
|
||||
with transaction.atomic():
|
||||
# Claims the one-time setup slot: the first of any
|
||||
# concurrent requests to reach this INSERT wins it, and
|
||||
# every other one raises IntegrityError instead of also
|
||||
# creating an admin account. See SetupLock's docstring.
|
||||
SetupLock.objects.create()
|
||||
user = form.save(commit=False)
|
||||
user.set_password(form.cleaned_data["password"])
|
||||
user.is_staff = True
|
||||
user.is_superuser = True
|
||||
user.save()
|
||||
except IntegrityError:
|
||||
messages.info(request, "Setup was already completed. Log in with that account.")
|
||||
return redirect("accounts:login")
|
||||
SetupWizardMiddleware._a_user_exists = True
|
||||
login(request, user)
|
||||
messages.success(request, "Welcome to Evection! Your admin account is ready.")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.18 on 2026-10-31 18:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("feeds", "0002_remove_folder"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="feed",
|
||||
name="claimed_at",
|
||||
field=models.DateTimeField(blank=True, null=True),
|
||||
),
|
||||
]
|
||||
@@ -40,6 +40,15 @@ class Feed(models.Model):
|
||||
fetch_error_count = models.PositiveIntegerField(default=0)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
# Set by poll_due_feeds' atomic claim (an UPDATE ... WHERE clause, not
|
||||
# select_for_update — Celery Beat and fetch_feed run in separate
|
||||
# transactions) and cleared once fetch_feed finishes, so overlapping
|
||||
# beat ticks or a fetch that runs long can't both dispatch the same
|
||||
# feed. A claim older than CLAIM_STALE_MINUTES (tasks.py) is treated as
|
||||
# abandoned and can be reclaimed, so a worker dying mid-fetch doesn't
|
||||
# wedge the feed forever.
|
||||
claimed_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
|
||||
+29
-4
@@ -4,6 +4,7 @@ from io import BytesIO
|
||||
|
||||
from celery import shared_task
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.articles.tasks import apply_filter_rules_for_feed
|
||||
@@ -14,13 +15,23 @@ from .services.fetcher import effective_interval_minutes, fetch_and_ingest
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# How long a claimed-but-unfinished fetch blocks the same feed from being
|
||||
# claimed again — must comfortably exceed FETCH_TIMEOUT_SECONDS plus parse/
|
||||
# ingest time, so a slow-but-healthy fetch is never raced by the next tick,
|
||||
# while a worker that died mid-fetch doesn't wedge the feed forever.
|
||||
CLAIM_STALE_MINUTES = 10
|
||||
|
||||
|
||||
@shared_task
|
||||
def poll_due_feeds():
|
||||
"""Find every active Feed whose polling interval has elapsed and
|
||||
dispatch a fetch_feed task for each — fan-out happens here, not via one
|
||||
Celery Beat entry per feed.
|
||||
"""Find every active Feed whose polling interval has elapsed, atomically
|
||||
claim it (so overlapping beat ticks or a slow-running previous fetch
|
||||
can't dispatch the same feed twice), and dispatch a fetch_feed task for
|
||||
each claimed feed — fan-out happens here, not via one Celery Beat entry
|
||||
per feed.
|
||||
"""
|
||||
now = timezone.now()
|
||||
claim_stale_before = now - timedelta(minutes=CLAIM_STALE_MINUTES)
|
||||
due_feed_ids = [
|
||||
feed.id
|
||||
for feed in Feed.objects.filter(is_active=True).only(
|
||||
@@ -28,9 +39,22 @@ def poll_due_feeds():
|
||||
)
|
||||
if _is_due(feed)
|
||||
]
|
||||
claimed_ids = []
|
||||
for feed_id in due_feed_ids:
|
||||
# The UPDATE's WHERE clause re-checks staleness at the database
|
||||
# level: it only claims rows nobody else has already claimed more
|
||||
# recently than CLAIM_STALE_MINUTES ago, so two workers racing this
|
||||
# same loop can't both get rowcount=1 for the same feed.
|
||||
claimed = (
|
||||
Feed.objects.filter(id=feed_id, is_active=True)
|
||||
.filter(Q(claimed_at__isnull=True) | Q(claimed_at__lt=claim_stale_before))
|
||||
.update(claimed_at=now)
|
||||
)
|
||||
if claimed:
|
||||
claimed_ids.append(feed_id)
|
||||
for feed_id in claimed_ids:
|
||||
fetch_feed.delay(feed_id)
|
||||
return len(due_feed_ids)
|
||||
return len(claimed_ids)
|
||||
|
||||
|
||||
def _is_due(feed: Feed) -> bool:
|
||||
@@ -48,6 +72,7 @@ def fetch_feed(feed_id: int):
|
||||
return None
|
||||
|
||||
result = fetch_and_ingest(feed)
|
||||
feed.claimed_at = None
|
||||
feed.save()
|
||||
|
||||
changed_article_ids = result.new_article_ids + result.updated_article_ids
|
||||
|
||||
@@ -40,6 +40,58 @@ def test_poll_due_feeds_dispatches_only_due_feeds():
|
||||
assert inactive_but_overdue.id not in dispatched_ids
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_poll_due_feeds_does_not_reclaim_a_feed_it_just_claimed():
|
||||
# Models a second beat tick (or an overlapping worker) running
|
||||
# poll_due_feeds before the first claimed fetch_feed has finished —
|
||||
# the feed must only be dispatched once.
|
||||
overdue = Feed.objects.create(
|
||||
feed_url="https://c.example.com/feed.xml",
|
||||
last_fetched_at=timezone.now() - timedelta(hours=2),
|
||||
fetch_interval_minutes=60,
|
||||
)
|
||||
|
||||
with patch("apps.feeds.tasks.fetch_feed.delay") as mock_delay:
|
||||
first_count = poll_due_feeds()
|
||||
second_count = poll_due_feeds()
|
||||
|
||||
assert first_count == 1
|
||||
assert second_count == 0
|
||||
assert mock_delay.call_count == 1
|
||||
overdue.refresh_from_db()
|
||||
assert overdue.claimed_at is not None
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_poll_due_feeds_reclaims_a_stale_claim():
|
||||
from apps.feeds.tasks import CLAIM_STALE_MINUTES
|
||||
|
||||
overdue = Feed.objects.create(
|
||||
feed_url="https://c.example.com/feed.xml",
|
||||
last_fetched_at=timezone.now() - timedelta(hours=2),
|
||||
fetch_interval_minutes=60,
|
||||
claimed_at=timezone.now() - timedelta(minutes=CLAIM_STALE_MINUTES + 1),
|
||||
)
|
||||
|
||||
with patch("apps.feeds.tasks.fetch_feed.delay") as mock_delay:
|
||||
dispatched_count = poll_due_feeds()
|
||||
|
||||
assert dispatched_count == 1
|
||||
assert mock_delay.call_args.args[0] == overdue.id
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@responses.activate
|
||||
def test_fetch_feed_task_clears_its_claim():
|
||||
feed = Feed.objects.create(feed_url="https://example.com/feed.xml", claimed_at=timezone.now())
|
||||
responses.add(responses.GET, feed.feed_url, body=GOOD_FEED_XML, status=200)
|
||||
|
||||
fetch_feed(feed.id)
|
||||
|
||||
feed.refresh_from_db()
|
||||
assert feed.claimed_at is None
|
||||
|
||||
|
||||
GOOD_FEED_XML = """<?xml version="1.0"?>
|
||||
<rss version="2.0"><channel>
|
||||
<title>Example Blog</title>
|
||||
|
||||
@@ -32,6 +32,11 @@ def test_service_worker_is_served_at_root_with_correct_type_and_scope(client):
|
||||
assert 'self.addEventListener("fetch"' in body
|
||||
# Mutations must stay network-only, never intercepted.
|
||||
assert 'request.method !== "GET"' in body
|
||||
# Logging out must purge PAGES_CACHE so a later offline navigation on
|
||||
# a shared/account-switched device can't serve another user's
|
||||
# previously cached authenticated pages.
|
||||
assert "caches.delete(PAGES_CACHE)" in body
|
||||
assert reverse("accounts:logout") in body
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
+28
-1
@@ -1,8 +1,30 @@
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from .base import * # noqa: F403
|
||||
from .base import env
|
||||
from .base import SECRET_KEY, env
|
||||
|
||||
DEBUG = False
|
||||
|
||||
# base.py falls back to a publicly known placeholder if SECRET_KEY isn't
|
||||
# set — fine for a throwaway dev DB, but production must never sign
|
||||
# sessions/CSRF tokens with a key anyone can read in this repo's history.
|
||||
# Fail startup rather than quietly running with a known key.
|
||||
if not SECRET_KEY or SECRET_KEY == "django-insecure-change-me-in-production":
|
||||
raise ImproperlyConfigured(
|
||||
"SECRET_KEY is missing or still the placeholder default. Set a unique, "
|
||||
"random SECRET_KEY in .env before running with prod settings — generate "
|
||||
'one with: python -c "from django.core.management.utils import '
|
||||
'get_random_secret_key; print(get_random_secret_key())"'
|
||||
)
|
||||
|
||||
# Health checks (scripts/upgrade.sh, an external uptime monitor, ...) hit
|
||||
# gunicorn directly over loopback, bypassing the reverse proxy entirely —
|
||||
# that request's Host header is "127.0.0.1:<port>", not the public domain
|
||||
# in ALLOWED_HOSTS, so without this Django 400s it. Harmless to always
|
||||
# allow: gunicorn's bind address is never reachable from outside this host
|
||||
# in the first place (see docs/install.md's "Reverse proxy" section).
|
||||
ALLOWED_HOSTS = [*ALLOWED_HOSTS, "localhost", "127.0.0.1", "::1"] # noqa: F405
|
||||
|
||||
# A reverse proxy (nginx, Caddy, Traefik, Nginx Proxy Manager on another
|
||||
# host, ...) is required in front of gunicorn in every deployment — see
|
||||
# docs/install.md — and it's always the one terminating TLS. This tells
|
||||
@@ -10,6 +32,11 @@ DEBUG = False
|
||||
# sets, and the redirect/cookie/HSTS settings below assume it's set.
|
||||
SECURE_SSL_REDIRECT = env.bool("SECURE_SSL_REDIRECT", default=True)
|
||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||
# /health/ is also exempted from the HTTPS redirect above: hit directly
|
||||
# over loopback (see ALLOWED_HOSTS above) it has no X-Forwarded-Proto
|
||||
# header to prove it's "secure", and there's no TLS listener on gunicorn's
|
||||
# own port to redirect to anyway.
|
||||
SECURE_REDIRECT_EXEMPT = [r"^health/$"]
|
||||
|
||||
# WhiteNoise serves /static/ directly from gunicorn instead of relying on
|
||||
# the reverse proxy to alias the staticfiles directory on disk — the proxy
|
||||
|
||||
+5
-4
@@ -295,6 +295,7 @@ git fetch --tags --force
|
||||
LATEST_TAG="$(git tag --sort=-creatordate | head -n1)"
|
||||
git checkout --detach "$LATEST_TAG"
|
||||
chown -R evection:evection /opt/evection/app
|
||||
sed -i "s/^EVECTION_PWA_CACHE_VERSION=.*/EVECTION_PWA_CACHE_VERSION=$LATEST_TAG/" .env
|
||||
sudo -u evection -H /opt/evection/venv/bin/pip install .
|
||||
sudo -u evection -H env DJANGO_SETTINGS_MODULE=config.settings.prod \
|
||||
/opt/evection/venv/bin/python manage.py migrate
|
||||
@@ -311,7 +312,7 @@ git tag v$(date +%Y.%m.%d)
|
||||
git push --tags
|
||||
```
|
||||
|
||||
Bump `EVECTION_PWA_CACHE_VERSION` in `.env` whenever a release changes cached
|
||||
static assets (CSS/JS/icons) — it's baked into the service worker's cache name, so
|
||||
changing it forces every installed PWA to drop its old cache instead of serving
|
||||
stale assets after the upgrade.
|
||||
`upgrade.sh` sets `EVECTION_PWA_CACHE_VERSION` in `.env` to the deployed tag on every
|
||||
run — it's baked into the service worker's cache name, so this forces every installed
|
||||
PWA to drop its old cache instead of serving stale assets after the upgrade. You don't
|
||||
need to bump it by hand.
|
||||
+46
-5
@@ -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 -----------------------------------------------------
|
||||
@@ -168,7 +204,7 @@ REDIS_URL=${EVECTION_REDIS_URL:-redis://localhost:6379/0}
|
||||
EVECTION_GUNICORN_BIND=$GUNICORN_BIND
|
||||
EVECTION_SIGNUP_ENABLED=False
|
||||
EVECTION_MIN_FETCH_INTERVAL_MINUTES=15
|
||||
EVECTION_PWA_CACHE_VERSION=v1
|
||||
EVECTION_PWA_CACHE_VERSION=${LATEST_TAG:-v1}
|
||||
EOF
|
||||
chown "$EVECTION_USER:$EVECTION_USER" "$ENV_FILE"
|
||||
chmod 600 "$ENV_FILE"
|
||||
@@ -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"
|
||||
done
|
||||
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 "==> Services installed. Checking status..."
|
||||
|
||||
+22
-4
@@ -72,6 +72,18 @@ echo "Deploying $LATEST_TAG (currently on: $CURRENT_REF)"
|
||||
git checkout --quiet --detach "$LATEST_TAG"
|
||||
chown -R "$EVECTION_USER:$EVECTION_USER" "$APP_DIR"
|
||||
|
||||
# Bump the PWA's cache-busting version to this release's tag on every
|
||||
# deploy, not just ones that happened to touch static assets — a missed
|
||||
# manual bump otherwise leaves installed PWAs serving a stale cached
|
||||
# shell/pages indefinitely. Cheap even when nothing cacheable changed:
|
||||
# it just makes the service worker open a fresh cache name next time it
|
||||
# activates.
|
||||
if grep -q '^EVECTION_PWA_CACHE_VERSION=' "$APP_DIR/.env"; then
|
||||
sed -i "s/^EVECTION_PWA_CACHE_VERSION=.*/EVECTION_PWA_CACHE_VERSION=$LATEST_TAG/" "$APP_DIR/.env"
|
||||
else
|
||||
echo "EVECTION_PWA_CACHE_VERSION=$LATEST_TAG" >> "$APP_DIR/.env"
|
||||
fi
|
||||
|
||||
echo "==> Installing updated dependencies"
|
||||
sudo -u "$EVECTION_USER" -H "$VENV_DIR/bin/pip" install --upgrade "$APP_DIR"
|
||||
|
||||
@@ -112,7 +124,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
|
||||
@@ -122,7 +143,4 @@ systemctl status evection-gunicorn --no-pager -l | head -10
|
||||
|
||||
echo
|
||||
echo "==> Deployed $LATEST_TAG."
|
||||
echo " If this release changed cached static assets (CSS/JS/icons), bump"
|
||||
echo " EVECTION_PWA_CACHE_VERSION in $APP_DIR/.env and restart evection-gunicorn"
|
||||
echo " again so installed PWAs drop their old cache instead of serving stale assets."
|
||||
echo " journalctl -u evection-gunicorn -f to watch logs."
|
||||
+7
-1
@@ -300,12 +300,18 @@ form p {
|
||||
}
|
||||
|
||||
.sidebar-tag-link {
|
||||
display: inline-block;
|
||||
padding: 0.15rem 0.4rem;
|
||||
margin: -0.15rem -0.4rem;
|
||||
border-radius: 0.375rem;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.sidebar-tag-link.active {
|
||||
color: var(--accent);
|
||||
background: var(--bg-row-selected);
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar-item-list {
|
||||
|
||||
+15
-1
@@ -66,8 +66,23 @@ async function cacheFirstForAsset(request) {
|
||||
return response;
|
||||
}
|
||||
|
||||
const LOGOUT_PATH = "{% url 'accounts:logout' %}";
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
const { request } = event;
|
||||
const url = new URL(request.url);
|
||||
|
||||
// Logging out ends this device's session, so any authenticated HTML
|
||||
// sitting in PAGES_CACHE must not outlive it — otherwise a later
|
||||
// offline navigation (shared device, different account logging in
|
||||
// next) could still serve a previous user's cached article pages.
|
||||
// Purging it synchronously with the logout request itself, rather
|
||||
// than via a postMessage from the page, means there's no race with
|
||||
// the navigation that follows.
|
||||
if (request.method === "POST" && url.pathname === LOGOUT_PATH) {
|
||||
event.respondWith(caches.delete(PAGES_CACHE).then(() => fetch(request)));
|
||||
return;
|
||||
}
|
||||
|
||||
// Mutations (mark-read, star, OPML upload, forms...) are always
|
||||
// network-only — never intercept anything but GET.
|
||||
@@ -78,7 +93,6 @@ self.addEventListener("fetch", (event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = new URL(request.url);
|
||||
if (url.pathname.startsWith("/static/")) {
|
||||
event.respondWith(cacheFirstForAsset(request));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user