`central` runs at `/opt/central` on **utility CT 104** — `ssh zvx@100.64.0.12` (mesh; preferred) or `192.168.1.104` (LAN). Runs as user `central`, three systemd units. Deploys are **manual, tag-based, detached-HEAD checkouts** — there is no deploy script and no CI/CD on this box. `zvx` has passwordless sudo. See [[central]] for architecture and current state.
Use this runbook whenever you need to deploy a new release or roll back.
---
## Key facts
| Item | Value |
|---|---|
| Deploy dir | `/opt/central` (owned `central:central`) |
| Virtualenv | `/opt/central/.venv` (uv-managed, editable install of `src/central`) |
| Lockfile | `/opt/central/uv.lock` |
| Env file | `/etc/central/central.env` (`CENTRAL_DB_DSN`, NATS URL; readable only by `central`) |
| Systemd units | `central-supervisor`, `central-archive`, `central-gui` (all `User=central`, in `/etc/systemd/system`) |
| Start order | `nats-server` + `postgresql@16-main` must be up first; `central-archive` Requires both; `central-supervisor` Requires nats; `central-gui` has no hard deps |
| Deploy model | Tracks **tags** — `git status` showing "detached HEAD" is normal, not a problem |
> **`central-migrate` env gotcha:** a bare `sudo -u central central-migrate` reads `.env` from the caller's cwd and the DB DSN is missing — it fails with `PermissionError: '.env'`. The systemd units supply it via `WorkingDirectory=/opt/central` + `EnvironmentFile=/etc/central/central.env`; manual calls must reproduce that with `cd /opt/central && set -a && . /etc/central/central.env && set +a && …` (the `central` user can read the env file). This wrapper is applied to every `central-migrate` invocation below.
> **Scripted path (preferred):** once `v0.14.6`+ is deployed, the repo ships `scripts/deploy.sh`, which automates everything below (pre-flight `pg_dump` to `/var/backups/central`, drift gate, fetch/checkout, `uv sync`, migrate, restart, verify, ERR-trap rollback guidance). Run:
> ```bash
> sudo /opt/central/scripts/deploy.sh v<NEW_TAG> # add -y to skip the confirm prompt
> ```
> **Bootstrap caveat:** the script ships *inside* the repo, so the `v0.14.6` cutover that first introduces it must be done with the manual steps below; every deploy after that can use the script. The manual procedure remains the source of truth and the fallback.
sudo -u central bash -c 'cd /opt/central && set -a && . /etc/central/central.env && set +a && /opt/central/.venv/bin/central-migrate --check' # should be clean
> **Migration 036 note:** This migration is already applied on this box. `central-migrate` will skip it (idempotent). That is expected, not an error.
### Step 4 — EONET go-global DB cutover
The code flag from PR #113 is necessary but **not sufficient**. After the code deploy, remove the Idaho `region` key from `config.adapters` to stop dropping global EONET events:
```bash
# Read current setting first
sudo -u central psql -d central -c "SELECT settings FROM config.adapters WHERE name='eonet';"
# Remove ONLY the region key (JSONB minus operator)
sudo -u central psql -d central -c "UPDATE config.adapters SET settings = settings - 'region' WHERE name='eonet';"
# Read back to confirm region is gone
sudo -u central psql -d central -c "SELECT settings FROM config.adapters WHERE name='eonet';"
# Ensure supervisor picks up the config change
sudo systemctl restart central-supervisor
```
> A config hot-reload mechanism may exist, but a supervisor restart is the guaranteed path.
Forward-only migrations have **no down-scripts**. To undo schema changes, restore the pre-flight dump:
```bash
sudo -u central pg_restore -d central --clean /tmp/central-pre-<tag>.pgdump
```
> Destructive. Understand exactly what you're reverting before running.
### EONET region key only (no redeploy needed)
If you only need to revert go-global without rolling back code:
```bash
sudo -u central psql -d central -c "UPDATE config.adapters SET settings = jsonb_set(settings, '{region}', '{\"east\":-111.0,\"west\":-117.5,\"north\":44.5,\"south\":41.8}') WHERE name='eonet';"
sudo systemctl restart central-supervisor
```
---
## Notes / gotchas
- No deploy automation, no CI/CD, no auto-pull — every deploy is manual.
- No automated DB backups on this box. The pre-flight `pg_dump` is the only safety net for migrations.
- Migrations are forward-only and idempotent; re-running `central-migrate` is safe.
- Detached HEAD after checkout is normal — the box tracks tags, not a branch.
-`uv sync` is always safe to re-run; it is a no-op if the lockfile hasn't changed.