Skip to content

The mockhub command

The operator runs a self-hosted installation with ./mockhub, from the installation directory, as a user who may use Docker. It works on the directory it lives in, wherever it is run from.

Command What it does
./mockhub verify BUNDLE [--key PUBLIC_KEY]... Checks a release bundle’s signature and every file’s checksum, with the keys in keys/ or those given
./mockhub load BUNDLE [--key PUBLIC_KEY]... Verifies the bundle, checks that this directory holds its files unchanged, loads its images and records its signed manifest
./mockhub install [--no-pull] [--unverified] [--admin-email ADDRESS [--admin-password-stdin]] Writes .env on the first run; afterwards checks the host and the release, creates the first administrator, then opens and verifies the stack
./mockhub status [--json] Checks the host, the release, every service, the workers, scheduled jobs, the licence and the last backup
./mockhub backup [--drain-timeout SECONDS] Takes a cold, complete recovery set in a maintenance window
./mockhub restore SET --kit-key PRIVATE_KEY [--replace-config] [--unverified] Restores a recovery set, here or on a clean host
./mockhub upgrade BUNDLE [--no-pull] [--drain-timeout SECONDS] Upgrades to the bundle’s release, with a backup in the same window
./mockhub upgrade --resume Finishes an upgrade that stopped, from the step that failed
./mockhub upgrade --rollback --kit-key PRIVATE_KEY [--restore-point SET] Puts back the previous release and the upgrade’s backup
./mockhub licence install FILE Installs a licence file; - reads it from standard input
./mockhub licence status [--json] Prints the licence state in one line, or as JSON
./mockhub licence report [--out FILE] Prints the usage report, or writes it to a file
./mockhub support-bundle [--logs] [--yes] [--out DIR] Writes an archive of facts about the installation for MockHub support
./mockhub tls reload Has the edge serve a renewed tls/cert.pem and tls/key.pem, in the files TLS mode
./mockhub compose ARGS... Runs docker compose with this installation’s files
./mockhub help Prints the list above
Option Of What it does
--key PUBLIC_KEY verify, load A release public key to trust besides those in keys/; repeat it for more
--no-pull install, upgrade Uses only images already on the host, such as those load loaded, and pulls none
--unverified install, restore Installs or restores with no recorded signed manifest, with a warning; status warns about it afterwards. For a build MockHub tests before it is bundled
--admin-email ADDRESS install The first administrator, created with ingress closed, asking for a password twice. Changes nothing once the installation has an administrator
--admin-password-stdin install Reads the first administrator’s password from the first line of standard input instead of asking
--json status, licence status One JSON object per check, or the licence state as JSON, for your monitoring
--drain-timeout SECONDS backup, upgrade How long queued work may take to finish before the services stop. 300 by default
--kit-key PRIVATE_KEY restore, upgrade --rollback The private key that opens the backup’s recovery kit
--replace-config restore Replaces this host’s .env with the set’s when they differ
--restore-point SET upgrade --rollback The upgrade’s backup, by name. Required once the new release may have served traffic: the restore discards every write made since
--out FILE licence report Writes the report to this file
--logs support-bundle Adds each service’s recent log lines, scrubbed, after showing them for review
--yes support-bundle Adds the logs without asking
--out DIR support-bundle Writes the archive to this directory instead of support/
Code Every command but status status
0 Done Every check is ok
1 Failed partway; the message says what state the host is in A check warns
2 Refused before anything changed A check fails

licence status answers like status: 0 when the licence needs nothing, 1 when it warns, such as near its expiry, and 2 when changes are refused.

The kernel, the Docker Engine and Compose versions, that the installation’s files and images are the signed release’s, free space, whether ingress is open, every service, readiness (the backend answering that its database and caches respond, or naming those that do not), a canary mock through the edge, that a worker polls each queue and the backlogs, failed messages, the scheduled jobs, the licence, an unfinished upgrade (where it stopped, whether its release may have served traffic, and its backup), and the age of the last complete backup. --json prints one {"check","status","detail"} object per line.

  • Workers fetch from their queues by polling and never show as RabbitMQ consumers, so a consumer count of 0 is normal. status watches how many fetches the broker counts on each queue for 12 seconds, so it takes that long to run. A queue nothing fetched from fails. It only warns when a worker is holding one of its messages, or when the broker’s counts are missing, restarted or unreadable.
  • Scheduled jobs are each job MockHub runs on a timer. A job is fine when it succeeded within three of its intervals, and pending while the scheduler is too new for its first run. It warns when a job never succeeded or has not succeeded within three intervals.
  • A figure status cannot read, such as a count from a database query that failed, is reported as unknown, never as zero.

MockHub sends no alert itself: your monitoring runs status and alerts on its exit code. Where it takes an HTTP call, this script, run every five minutes by cron as the user that runs ./mockhub, posts every check as JSON lines to MOCKHUB_ALERT_URL whenever one is not ok, and sends nothing otherwise:

Terminal window
cd /opt/mockhub || exit 1
out=$(./mockhub status --json 2>/dev/null) && exit 0
printf '%s\n' "$out" | curl -fsS --max-time 10 -H 'Content-Type: application/x-ndjson' \
--data-binary @- "$MOCKHUB_ALERT_URL"

Deliver one test alert before relying on it: stop a worker with ./mockhub compose stop log_worker, run the script, check that your receiver got the queue.logs failure, then ./mockhub compose start log_worker.

Its thresholds can be set in .env. MockHub has not measured them yet, so treat them as a starting point:

Setting Default What it decides
STATUS_DISK_WARN_GB 20 Free space, in GB, under which status warns
STATUS_DISK_FAIL_GB 5 Free space, in GB, under which status fails
STATUS_BACKLOG_WARN 1000 Messages waiting in a queue above which status warns
BACKUP_MAX_AGE_HOURS 26 Hours since the last complete backup after which status warns
CANARY_URL Unset The full https:// address of a mock whose answer never changes
CANARY_BODY Unset That mock’s exact body. With both set, status and every maintenance window check a real mock end to end; without them, status warns
Path Holds
.env The installation’s settings and secrets. Never commit it or send it to anyone
release.env The release and its images; it ships with each release
keys/ The release public keys this installation trusts
tls/ Your certificate and key, in the files TLS mode
backups/ Recovery sets, unless BACKUP_DIR names another place
recovery-recipients/ The public keys each backup’s recovery kit is encrypted for
releases/ The previous releases’ files, for a rollback; the last three
support/ Support bundles
state/ What the script records: the installed release and its signed manifest, the maintenance flag, upgrades in progress and their history, and, while a backup or restore runs, the recovery kit’s owner-only staging

Report a problem with this page