Skip to content
Language:DeutschEnglish Last updated: 2026-11-30

Lotte: operation

This page describes what it takes to run Lotte on a server: installation, tenants, clients and keys, the workers, the recurring tasks, backup, monitoring and recovery. What Lotte is and how the data is laid out is in the overview; every command with its options is in the command reference.

With Anton as a Service, k & r runs Lotte. On premises, the operating institution sets up the service following this page.

Requirements

  • PHP 8.3 with the usual extensions of a Laravel application, Composer;
  • MySQL 8, the same instance as the tenants' Anton databases, with a database user of Lotte's own that may create the databases <slug>_archiv and has no rights on Anton's databases;
  • a web server with a host name of its own for Lotte, with TLS;
  • a storage location for the tenants' folders, large enough for the masters and their versions;
  • the tools of the checks and derivatives, as Anton needs them: ClamAV (clamd), Siegfried (sf), veraPDF, ImageMagick, Ghostscript, poppler-utils, qpdf, MuPDF, libtiff-tools, ExifTool, file, FFmpeg, LibreOffice (headless), Tesseract with the languages of the holdings, ocrmypdf and img2pdf;
  • for the second check of the OCFL objects, ocfl-py (Python), with the command ocfl-validate.py on the path.

Lotte needs no connection to Anton and opens no connection to the outside; the tools run as programs on the server.

Installation

Lotte is a Laravel application and is installed like one:

composer install --no-dev --optimize-autoloader
cp .env.example .env
php artisan key:generate

The .env holds the database connection (Lotte's own user; Lotte chooses the database per tenant itself), the address of the service and Lotte's settings:

Variable Meaning Default
APP_URL the address of the service; signed URLs point to it
DB_CONNECTION stays tenant: the database follows the tenant tenant
DB_HOST, DB_PORT, DB_USERNAME, DB_PASSWORD the MySQL instance and Lotte's database user
QUEUE_CONNECTION stays database: the queue lives in the tenant's database database
LOTTE_BASE_PATH where the tenants' folders lie: <base>/<slug>/ storage/app/tenants
LOTTE_TENANTS_FILE the tenants file tenants.php
LOTTE_VIRUS_CHECK required refuses a file ClamAV could not check; optional accepts it with a warning (development only) required
LOTTE_CLAMD_SOCKET the socket of clamd
LOTTE_CLAMD_TIMEOUT the least seconds clamd gets; for large files the wait grows with LOTTE_VIRUS_SCAN_SECONDS_PER_GB 30
LOTTE_VIRUS_SCAN_SECONDS_PER_GB the wait per GiB that clamd gets for a large file or a part 240
LOTTE_VIRUS_SCAN_WHOLE_MAX_SIZE bytes; larger files are checked in parts 512 MiB
LOTTE_VIRUS_SCAN_MAX_SIZE the most bytes ClamAV checks whole; above it only in parts 2 GiB
LOTTE_VIRUS_SCAN_PART_SIZE, LOTTE_VIRUS_SCAN_PART_OVERLAP size of the parts and their overlap in bytes; a part must stay below clamd's StreamMaxLength. The result is then «clean in parts» 256 MiB, 1 MiB
LOTTE_IDENTIFICATION required refuses a file when Siegfried is missing; an unknown format is never refused required
LOTTE_OPERATOR_LOG the server's operator log, one JSON line per run of a command that writes storage/logs/operator.log
LOTTE_FORMAT_VALIDATION_INVALID warn accepts an invalid file and records it, reject refuses it warn
LOTTE_VERAPDF_BINARY, LOTTE_MUTOOL_BINARY veraPDF and MuPDF, where they are not on the path
LOTTE_PACKAGE_RETENTION_DAYS after how many days a forgotten package is discarded 7
LOTTE_OCR_LANGUAGES Tesseract's languages for OCR deu+eng+fra+ita
LOTTE_SIGNED_URL_MINUTES how long a signed URL is valid 15
LOTTE_DERIVATIVE_RETRY_AFTER after how many seconds a client should ask for a derivative again 30
LOTTE_HEALTH_QUEUE_WARNING_MINUTES after how many minutes of a job waiting monitoring warns 15

The web server points to public/. Lotte needs no sessions and no login; everything except /health and the signed URLs requires a key.

Tenants

A server's tenants are listed in the tenants file (tenants.php, not in the repository; template tenants.example.php). Per tenant: the database (default <slug>_archiv), the format policy rules that apply at ingest, and whether images and PDFs without a text layer get their text by OCR:

return [
    'beispiel' => [
        'database' => 'beispiel_archiv',
        'format_policy' => ['tiff_zip' => true],
        'ocr' => false,
    ],
];

A new tenant gets its folder and its database with lotte:tenant:init; the command creates ocfl/, derivatives/, text/ and work/, creates the database and migrates it. After an update of Lotte, lotte:migrate --all migrates the databases of all tenants.

php artisan lotte:tenant:init beispiel
php artisan lotte:migrate --all

Clients and keys

A client is a system that uses Lotte through the API; for Anton, one client per tenant. It gets a key valid for its own tenant only, and abilities:

Ability allows
read reading objects, files, derivatives, text and the change feed, viewing jobs
ingest describing, uploading, checking, committing and discarding packages
jobs creating and viewing jobs
metadata giving an object a new metadata copy
withdraw withdrawing an object

lotte:client:create creates the client and shows the key once; Lotte stores only its hash. lotte:client:revoke revokes all keys of a client. GET /t/<slug>/whoami shows whether a key works.

php artisan lotte:client:create beispiel anton --abilities=read,ingest,jobs,metadata,withdraw
curl -H "Authorization: Bearer <key>" https://<lotte>/t/beispiel/whoami
php artisan lotte:client:revoke beispiel anton

Purging and the administration of tenants and clients exist on the command line only, for operators with access to the server.

One worker per tenant

Checks, derivatives, text and jobs run on the queue, and the queue lives in the tenant's database. Each tenant therefore needs a worker of its own, lotte:work <slug>, as a service that restarts after a crash (with systemd or Supervisor, for instance). After an update of Lotte the workers are restarted so that they load the new code. A job may run for a long time; a conversion taking hours is not handed out twice.

php artisan lotte:work beispiel

Recurring tasks

Lotte brings no schedule of its own; operations set up the recurring tasks as cron jobs, per tenant where the command requires a tenant. Recommended:

Command Interval Purpose
lotte:prune-packages --all daily discard packages that are neither committed nor discarded after the retention time
lotte:derivatives <slug> --backfill nightly queue missing derivatives, those with fewer than three failures, and stale ones
lotte:derivatives <slug> --reconcile occasionally align the state of the derivatives with the files in derivatives/ and text/
lotte:verify <slug> --share=12 --ocfl --report=<file> monthly check a twelfth of the objects against their digests and with ocfl-py: those never checked first, then those checked longest ago; so every object is checked once a year
lotte:verify <slug> --sample=<n> --report=<file> after every update of Lotte check a sample of <n> random objects
lotte:health every few minutes, from monitoring state of the service and of each tenant

A full check reads every file; with several terabytes, the interval wants planning, as with Anton's integrity check.

With --report, lotte:verify writes a report as JSON: the copy and storage root checked, the selection (all, named objects, a package, a share, a sample), whether ocfl-py checked too, start and end, counts and the outcome per object. It is the proof also of a run without a finding, which leaves no trace in the objects; the operation keeps it under Git. --report works only without --queue: the cron therefore calls lotte:verify directly, not through the queue, and must be allowed to run as long as the twelfth takes. The check is proven only once the reports of these runs are kept under Git in operation.

Backup

A tenant is backed up when two things are backed up:

  • its database <slug>_archiv, as a dump in the same nightly run as the tenant's Anton database;
  • its folder <base>/<slug>/, as a snapshot like the media files, to another system and another location.

ocfl/ is irreplaceable: it holds the masters, their earlier versions, the metadata copies and the preservation events. OCFL is self-describing; a backed-up folder can be checked and read without Lotte's database. derivatives/ and text/ can be made again, work/ holds only what has not been committed yet, and in work/quarantine/ the damaged objects that lotte:repair replaced. Besides the index, the database holds what is not in the folder: clients and keys, open packages, jobs and the change feed.

Export

lotte:export copies a tenant's objects into an OCFL storage root of their own somewhere else, for instance for a handover, a move to other storage or a copy outside Lotte. --all takes every object together with the tombstones of purged objects, --object only those named.

php artisan lotte:export beispiel --all --to=/mnt/uebergabe/beispiel --operator=<name>

Each object goes across with all its versions, as it is, and is checked at the target with the library and with ocfl-py and compared with the inventory copied. An object that fails the check is removed from the target again. An object already there with the same inventory stays; a different one is never overwritten. The target is empty, missing or the storage root of an earlier export, never a place in the tenant's folder. lotte-export.json at the target records who exported what, when and with which outcome per object; a new run replaces the file. The command ends with 1 when an object could not be exported.

Monitoring

Two ways show the state, neither asks Anton:

  • GET /health answers without a key with the overall state only, {"status": "ok"} (or warning, critical). Since the address is public, it names no tenant, no path and no message. The HTTP status is 200 while nothing is critical, otherwise 503.
  • lotte:health runs the same check on the server and gives the details: the storage location and every tenant where something is wrong. It prints one line for Nagios (LOTTE OK - …) and exits with 0 (OK), 1 (WARNING) or 2 (CRITICAL).

Critical: the storage location or an area of a tenant is not writable, a database is not reachable. A warning is given when a job has waited longer than the set time (then no worker is taking jobs). Derivatives given up after three failures are named on the line as a finding (kr: 3 derivatives given up (finding, …)), but the state stays OK: usually the file itself is broken, and a warning would stand until someone cleans the data. lotte:derivatives <tenant> --given-up lists them. Anton hears of each one in the change feed (derivative.failed with given_up).

Operator protocol

Every command takes the option --operator=<name>: the person running it. Without it, SUDO_USER counts, that is, whoever called sudo -u <account> php artisan …; else the Unix user, on the server mostly just the service account. Every run of a command that writes (ingest, commit, discard, metadata, withdrawal, purge, repair, verify, derive, OCR, format migration, lotte:derivatives, lotte:prune-packages, lotte:rebuild-index, creating and revoking clients, setting up and migrating a tenant) is recorded: person, account, host, the arguments and options given, start, end and exit code, also when the run fails. This goes into the tenant's table operator_actions and as a JSON line into the server's operator log (LOTTE_OPERATOR_LOG), which also holds the runs over several tenants. Reading commands such as lotte:show or lotte:health are not in it.

lotte:purge and lotte:repair need a person: --operator or a call through sudo. The bare service account is not enough there.

Recovery

A tenant is restored from its folder and its database dump. As dump and snapshot are rarely taken at the same moment, the folder may be newer than the index in the database, or the database may be missing altogether. Then lotte:rebuild-index <slug> rebuilds the index from the folder: reference and state from metadata/object.json, PRONOM ID and MIME type from the format identification in metadata/events.json, and the state of the derivatives from the files in derivatives/ and text/. With --prune it removes rows whose object is no longer in the folder. Missing derivatives are then made by lotte:derive or by the nightly lotte:derivatives --backfill.

php artisan lotte:rebuild-index beispiel
php artisan lotte:derive beispiel

lotte:rebuild-index writes no entries into the change feed. Where it changed the index it says so; the clients then resync those objects. Clients, keys, open packages, jobs and the change feed exist only in the database. If it is missing altogether, lotte:tenant:init creates it empty before lotte:rebuild-index runs. The clients then get new keys, reset their position in the change feed to 0 and resync all objects, because the new feed starts empty.

Repairing a damaged object

When lotte:verify reports an object as invalid, lotte:repair takes it back from another copy. --from names the storage root of a copy, as a decrypted view (copy 2, else 3, 4); several --from are tried in order.

php artisan lotte:repair beispiel <uuid> --from=/mnt/kopie2/beispiel/ocfl --from=/mnt/kopie3/beispiel/ocfl --operator=<name>
php artisan lotte:repair beispiel <uuid> --from=/mnt/kopie2/beispiel/ocfl --from=/mnt/kopie3/beispiel/ocfl --operator=<name> --confirm

It takes the first copy that is valid against its inventory and with ocfl-py, is at the same head (version) as the index and holds the same master; where the damaged object's inventory is still intact, the copy must also have that same inventory. A copy at an earlier head is refused, because the versions since would be lost with it. Without --confirm the command only says which copy it would take. With --confirm it stages the copy in work/repair/, checks it there once more, moves the damaged object to work/quarantine/<uuid>-<time> and puts the copy in its place. A recovery event in a new version then records which copy, where the damaged object went and who repaired it. A sound object is left as it is. When the quarantine is emptied is not decided yet.