The release-notes reminder to manually bump this and restart gunicorn
was easy to miss or forget, leaving installed PWAs on a stale cached
shell/pages after an upgrade that changed static assets. upgrade.sh
now sets it to the deployed tag itself before restarting services, so
there's no manual step and no cache-invalidation window to miss.
install.sh does the same on first install for consistency.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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>
curl isn't installed by default on this install's host, and nothing else
in install.sh/upgrade.sh actually requires it — the venv's own Python
(which obviously exists by the time this check runs) can make the same
HTTP request via urllib, so drop the curl dependency entirely rather than
adding it to the prerequisites.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
systemctl enable --now only starts a service if it's stopped — on a
re-run where a unit file's ExecStart changed (e.g. picking up a new
EVECTION_GUNICORN_BIND), the already-running process just kept running
on its old command line indefinitely. This is exactly what happened
switching gunicorn from a Unix socket to TCP: the new unit file was
written and daemon-reload'd, but gunicorn itself never restarted, so it
kept listening on the old socket. Restart explicitly instead of relying
on --now.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
gunicorn previously only ever bound to a Unix socket, which assumes the
reverse proxy is nginx running on this same host — it can't be reached by
a proxy on a different machine at all (e.g. Nginx Proxy Manager on its own
box), which is this project's actual deployment target. Switch gunicorn to
listening on a plain TCP address instead, controlled by a new
EVECTION_GUNICORN_BIND setting in .env.
install.sh now asks whether the proxy is local or remote and picks a
sensible bind default either way (127.0.0.1:8000 vs 0.0.0.0:8000, with a
reminder to firewall the port in the remote case), and no longer tries to
automate nginx/certbot itself — docs/install.md's new "Reverse proxy"
section covers both shapes instead, since which proxy and where it runs is
the operator's choice, not something this script should assume or set up.
upgrade.sh's health check now curls the TCP bind instead of the old socket
path.
Also add WhiteNoise so gunicorn serves /static/ itself: the old approach
(nginx aliasing the staticfiles directory on disk) silently breaks the
moment the proxy isn't on this host and can't see this filesystem.
nginx.conf.example's own /static/ alias becomes an optional same-host perf
optimization rather than a requirement.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The idempotency check only looked for the venv directory's existence, so
a venv left behind by an earlier failed run (e.g. missing ensurepip, as
just hit) — present but with no bin/pip — made every later re-run skip
venv creation entirely and then fail on a pip that was never created.
Check for bin/pip specifically and wipe+recreate if it's missing.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
On Debian/Ubuntu, python3-venv (ensurepip support) is a separate package
from python3 itself, and apt installing just python3 leaves venv creation
failing partway through install.sh — after the system user, chown, and
git checkout have all already happened. Check for it up front alongside
the Python version check, and document the apt package in install.md's
prerequisites.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
install.sh chowns $APP_DIR to the service user, but its own (and
upgrade.sh's) git fetch/checkout steps run as root per the previous fix —
git refuses that combination by default ("detected dubious ownership"),
which is exactly what happens re-running install.sh after an earlier run
got far enough to chown the checkout. Add the directory to root's
safe.directory list before touching it with git.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
EVECTION_HOME (the venv's parent directory, e.g. /opt/evection) was never
chowned to the service user — only the app checkout inside it was — so
venv creation failed with Permission denied whenever EVECTION_HOME was
created by root before running the script (the documented quick-install
steps do exactly that: mkdir + git clone as root, then run install.sh).
Also run the release-tag git fetch/checkout as root instead of
sudo -u $EVECTION_USER in both install.sh and upgrade.sh: the service
user has no reason to have its own git credentials configured, so running
as it just means the private repo's auth prompt hangs the script (as seen
on this install) or silently fails. Root already has working credentials
from the initial clone. Added GIT_TERMINAL_PROMPT=0 so a credential
problem fails fast instead of hanging on a prompt either way.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The "no tags found" error suggested git tag v1.0.0, which doesn't match
how this project's tags are actually named — generates today's date into
the example instead. No behavior change: git tag --sort=-creatordate
already sorts by actual tag creation time regardless of the tag name's
format, so the date-based scheme worked with the existing logic already.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
scripts/upgrade.sh now fetches tags and does a detached-HEAD checkout of
the latest one (git tag --sort=-creatordate | head -n1), matching the
ds-chat project's deploy/upgrade.sh exactly rather than a plain git pull
on whatever branch happened to be checked out. Errors clearly if the repo
has no tags yet (true for Evection right now — nothing to deploy until a
release is tagged and pushed), and no-ops cleanly if already on the
latest tag. scripts/install.sh does the same tag pin on first install
(falling back to whatever's checked out if no tags exist yet), so the
very first deploy is consistent with every upgrade after it.
Added a GET /health/ endpoint (apps.core.views.health) that checks DB
connectivity and is exempt from the first-run setup redirect, for the
upgrade script's post-restart verification (curled over the gunicorn
unix socket, same as ds-chat's curl-based check) and for any external
uptime monitor.
While wiring the setup-wizard exemption for /health/, found that
SetupWizardMiddleware._a_user_exists's reset fixture was scoped only to
apps/accounts/tests.py, so a test anywhere else that creates a user and
makes a request could leak a stale "a user exists" into later test files
with no reset — confirmed this concretely by temporarily breaking the new
exemption and watching the "works before setup" test still pass purely
from accounts/tests.py leaving the module-order-adjacent apps/articles
tests to poison the shared class attribute. Moved the fixture to a new
top-level conftest.py so it's autouse across every test file, which also
makes the new health-check test meaningful regardless of run order.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Keeps the traditional pip+systemd+nginx deployment (no Docker, per the
original decision) but automates the manual steps already in
docs/install.md instead of leaving them as copy-paste instructions:
- scripts/install.sh: creates the system user, virtualenv, generates
.env (auto SECRET_KEY, prompts for domain/SQLite-vs-Postgres —
non-interactive via EVECTION_ALLOWED_HOSTS/EVECTION_DATABASE_URL/etc
for scripted provisioning), migrates, collects static files, installs
the systemd units (sed-substituted for the actual install path/user
rather than hardcoded to /opt/evection), and optionally sets up nginx +
certbot. Safe to re-run — skips what's already done rather than
redoing it, and never overwrites an existing .env.
- scripts/upgrade.sh: git pull, reinstall, migrate, collectstatic,
restart whichever of the three services are actually present (handles
the combined worker+beat deployment variant too).
docs/install.md now leads with the script as the recommended path, with
the existing step-by-step instructions kept below for anyone who wants
to understand or customize what it's doing.
Verified: shellcheck clean on both scripts (via a throwaway shellcheck-py
venv, since neither apt nor pip --user were available non-interactively);
the systemd-unit and nginx-config sed substitutions produce correct
output against the real template files; the generated .env format
round-trips through `manage.py check` under config.settings.prod without
error. Did not actually run install.sh against a real system — that
creates a system user and installs systemd units, which needs the
person deploying it to run (and review) themselves.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>