All chapters

Operations

Reviir is meant to be run by people who have other things to do. It updates itself under rules you set, can always be rolled back, and tells you when it is not well.

Updates#

A separate, privileged updater service replaces the program; the program never replaces its own files. It follows a release channel (stable, beta or canary; Updates:Channel) published on get.reviir.com, whose manifest is signed with ECDSA P-256 and lists a SHA-256 for every archive. It refuses a manifest that is unsigned, tampered with, expired, yanked or older than what is installed.

What an update does
StepWhat happens
CheckEvery 4 hours (Updates:CheckIntervalMinutes), within the policy below.
Download and verifyThe archive is checked against the signed manifest.
StageIt is unpacked beside the running release.
PreflightThe new program migrates a copy of your database and health-checks it. A problem stops the update here, with no downtime.
Back upA consistent database backup is taken.
SwitchThe current link moves to the new release and the service restarts, a pause of a few seconds.
Health gateFor up to 2 minutes (Updates:HealthTimeoutSeconds) the updater waits for /health/ready to be healthy and /status to report the new version.
Keep or roll backOn failure it switches back to the previous release, marks the new one bad and, if the old program refuses the migrated schema, restores the backup. Data written since the update is lost in that last case only.

Who decides when#

Update policy
SettingServerEdge
Default mode (Updates:Mode)Approve: an Owner or Admin of the system organisation approves on the Updates page, and system admins are e-mailed when an update is available, fails or rolls back.Auto: it updates itself, following its own server and never ahead of it.
Window (Updates:Window)02:00 to 05:00 by defaultThe same, with a random jitter, and it waits for live viewers for up to 24 hours.
Other modesOff still reports that a version is available; Auto installs inside the window.—
  • Updates:PinVersion holds an installation at a version. Updates:KeepReleases (3) controls how many old releases are kept for rollback.
  • The official releases need no token. A private mirror (Updates:ManifestUrl) can take one in Updates:AuthToken; a mirror in a private GitHub repository needs a GitHub token that can read it, or every check fails with a 404. The installers keep the token they were given (--token / -Token) in update-token.json in the config directory. It is sent only over HTTPS, and only to GitHub and to the host of Updates:ManifestUrl, never to get.reviir.com.
  • With Caddy in front, an update is a pause of a few seconds in which requests wait, not an error.
  • A server in a container has no updater: a newer image replaces it, and the Updates page says so. See Docker.

Backups#

Reviir writes a backup every night (Backup:Time, 03:30 by default) into backups/ in the data directory and keeps the last seven (Backup:Keep). A backup is a folder: a consistent copy of the database made with SQLite's VACUUM INTO and verified with PRAGMA quick_check, the signing keys, the Zigbee state, the settings files and a manifest with a SHA-256 hash of each file. The server keeps running while it is written. Reviir --backup [dir] [--include-blobs] writes the same folder on demand, and the updater takes its own backup before every update and keeps the last five.

The backup is on the same disk as the data unless you move it: set Backup:Path to another volume or a mounted share, or copy the folder off the machine. A backup holds your secrets, so protect it. Reviir --restore <folder> --yes puts a backup back while the server is stopped; it checks the hashes first and keeps the files it replaces in a pre-restore-… folder. Try a restore once before you need one.

What to back up
WhatWhereHow
The databasereviir.dbIn every backup.
Picturesblobs.dbOnly with Backup:IncludeBlobs or --include-blobs: the file can be tens of gigabytes, and storing and showing pictures waits while it is copied.
Signing keys for sign-in cookieskeys/In every backup. Losing it signs everyone out.
The Zigbee network keyzigbee/In every backup. Losing it means re-pairing every device.
Configuration/etc/reviir or C:\ProgramData\Reviir\configThe JSON files are in every backup. They hold your secrets: protect the backup.
Video clipsclips/Never in a backup. Copy the folder yourself if you need them.

Retention#

An hourly job deletes old data in small batches. It never touches ongoing incidents, rules, sensors or people. A value of 0 keeps that category forever.

Retention defaults
DataKeptSetting
Readings, events, person events, raw requests, rule firings90 daysRetention:EventDays
Pictures and their detections30 daysRetention:ImageDays
Resolved incidents365 daysRetention:ResolvedIncidentDays
Video clips30 daysRetention:ClipDays

Health#

Health endpoints
EndpointAnswers
/health/liveOnly that the process is up.
/health/readyWhether it is ready to serve: the database, the picture store, the listeners, disk and the write buffer. Use this one for monitoring and load balancers.
/healthThe same checks, with detail for a signed-in user.
/statusVersion and uptime; more for a signed-in user.
  • An anonymous caller gets the status word only.
  • Degraded (the service still works): under 1 GB of free disk, a full write buffer, a gap in availability, the detection model failing, an unplugged Zigbee dongle.
  • Unhealthy: the database or picture store cannot be read, or a listener could not start. A listener that fails does not stop the server.
  • On start-up Reviir checks its own health and refuses to start if it is unhealthy.

Logs#

Logs go to the console (the journal under systemd) and to daily files in <DataDir>/logs/, kept 14 days with a 100 MB cap per file. Tokens appear only as their first eight characters, ffmpeg's output is run through the same redaction because it echoes camera URLs, and every request has an X-Request-ID for correlating a report with a log line.

The database and rollbacks#

Reviir stores its data in an embedded SQLite database (WAL mode) plus a second file for pictures. The schema is migrated automatically on start, and migrations only add (tables, columns, indexes), so the previous release still runs on a migrated database and a rollback needs no restore. A release that must break that promise raises a minimum level; an older program then refuses to start with exit code 3 and the updater restores the backup. After a rollback, rules that use newer features are skipped with a warning rather than failing.

The data directory#

What is in the data directory
ItemHolds
reviir.dbEverything except pictures: places, sensors, readings, events, incidents, rules, users.
blobs.dbPictures and their detections.
keys/Keys that sign cookies, antiforgery tokens and the sign-in bot trap.
zigbee/The Zigbee network key and state.
clips/Video clips.
logs/, backups/, update/Log files, database backups, updater state and the offline inbox.
.edge/, models/ffmpeg and the detection model, unpacked from the program on first use.