Set up · 04
Deployment and release
A release moves code and database state together. The shipped release script keeps the sequence explicit and refuses to restart when production checks report a configuration gap.
Release model
One Gunicorn service and one Nginx site share the application directory. A release is a purchased ZIP extracted over the existing application, followed by dependency install, migrations, staff roles, static collection, production checks, a service restart and readiness. There is no Git remote, asset pipeline or background worker to update.
Preflight
cd /srv/perfumz
sha256sum /srv/perfumz-<edition>-<version>.zip
cat /srv/perfumz-<edition>-<version>.zip.sha256
.venv/bin/python manage.py check --settings config.settings_production
.venv/bin/python manage.py makemigrations --check --dry-run --settings config.settings_productionCompare the checksum with the value published beside the marketplace download. Keep the pre-release ZIP and a fresh database backup until the new release has served real traffic successfully.
Install the new release
Download the new ZIP from the same purchase account, verify its sidecar, then stop the service and extract it over the installation. The archive deliberately excludes .env, .venv/, media/, staticfiles/, logs/ and the database, so those runtime files remain in place.
sudo systemctl stop perfumz
sudo unzip -o /srv/perfumz-<edition>-<version>.zip -d /srv
sudo chown -R perfumz:perfumz /srv/perfumzFor a clean installation, extract into an empty directory instead of over an existing one. An in-place update leaves files that the new release no longer ships.
The release script
cd /srv/perfumz
bash deploy/release.sh --no-pull| Step | What happens |
|---|---|
| Source | Uses the extracted release as-is. --no-pull makes the ZIP-only workflow explicit. |
| Dependencies | pip install -r requirements.txt inside the existing virtualenv. |
| Checks | manage.py check and a clean check --deploy before restart. |
| Schema | migrate then sync_staff_roles. |
| Assets | collectstatic, followed by read permissions for Nginx. |
| Service | sudo systemctl restart perfumz. |
| Readiness | Polls the public /health/ready/ URL with a loopback fallback. |
Manual release sequence
.venv/bin/pip install -r requirements.txt
.venv/bin/python manage.py check --settings config.settings_production
.venv/bin/python manage.py migrate --settings config.settings_production
.venv/bin/python manage.py sync_staff_roles --settings config.settings_production
.venv/bin/python manage.py collectstatic --noinput --settings config.settings_production
.venv/bin/python manage.py check --deploy --settings config.settings_production
sudo systemctl restart perfumz
curl -fsS http://127.0.0.1:8007/health/ready/If check --deploy reports a warning, fix the environment or settings before restarting. The release script treats warnings as a failed release.
Rollback
Application rollback restores the previous release ZIP and restarts the service. Database migrations are forward-only; if a migration changed data, restore the pre-release backup or write a deliberate reverse migration. Keep the previous ZIP and its checksum until the new release has served real traffic successfully.
sudo systemctl stop perfumz
sudo unzip -o /srv/perfumz-<edition>-<previous-version>.zip -d /srv
.venv/bin/pip install -r requirements.txt
.venv/bin/python manage.py collectstatic --noinput --settings config.settings_production
sudo systemctl restart perfumz
curl -fsS http://127.0.0.1:8007/health/ready/Never roll back by deleting the database or media directory. Restore into a separate database, verify it, then switch the application.
Release checklist
- The test suite and translation audit are green.
check --deployhas no warnings.- A fresh backup exists and has been copied off the VPS.
- Static and media permissions are readable by Nginx.
- The readiness endpoint returns 200 on the loopback port and the public URL.
- One staff sign-in, one product page and one checkout smoke test pass after the restart.