trunkjet

Run your own server

On this page

Installing a trunkjet server

From a clean Linux host to a running, monitored server. The steps below are what make package-server-test-vm (tools/release/server_package_test.py, on an Ubuntu 24.04 test VM) runs against a 5-node FoundationDB, plus the parts that test cannot do for you (DNS, real certificates, an identity provider). make package-server-test covers the container image. Every setting is described in the administrator guide. Installing the user clients: Install the CLI and the desktop app.

Not supported yet (each is called out where it applies):

GapTodayTracked
Signed packages and imagesThe .deb, the archives and the image are unsigned; verify them with SHA256SUMS from a trusted channelT080 (no signing identity)
.rpm, Windows/macOS server buildsDebian/Ubuntu .deb, the container image and the Linux tar.gz onlyWP6
FoundationDB TLSThe client honours FDB_NETWORK_OPTION_TLS_* but this is untested and undocumented; keep the FDB network privateWP3, T076
Reference FDB topology3-node (double) and 5-node (triple) reference layouts, failure-tested in Docker on one host; process classes and FDB TLS are not exercised by the tests, no multi-host or multi-region run yetWP3, T076
Rolling and mixed-version upgradesNot qualified: stop every tjetd and tjet-worker, upgrade, startWP5, T077
Certificate reloadA new TLS certificate needs a restart of tjetdWP6
Content-store replicationlocal is single-host (the doctor warns); s3 durability is the operator's declaration, not measured (the failure tests use one Garage node; a replicated S3 store is not qualified)WP3
FoundationDB-level disaster recovery drillfdb-backup and fdbrestore work (runbook fdb-restore); no scheduled drill with measured RPO/RTOWP4, T079
Key rotation proceduresNone for the cursor key or OIDC client secretsT078
JSON logs, OpenTelemetryText logs to the journal; Prometheus metrics onlyWP6

1. Host

  • Debian 13 or Ubuntu 24.04 or later, x86_64, with systemd (the release binaries need glibc 2.39 or later). NTP-synchronised clock (admin guide §3).
  • A FoundationDB 7.3 cluster reachable from the host (its own hosts in production; at least three for double, five for triple redundancy). The host needs only the cluster file and the client library.
  • For more than one tjetd host: an S3-compatible object store reachable over https.

2. Install the packages

The server package depends on FoundationDB's client package, which is not in Debian or Ubuntu: take it from the FoundationDB release that matches the cluster.

curl -LO https://github.com/apple/foundationdb/releases/download/7.3.77/foundationdb-clients_7.3.77-1_amd64.deb
echo "b6c263723009bddbc30b6ae8cf9854340bd35cef14152abb0da8fb5af2b91254  foundationdb-clients_7.3.77-1_amd64.deb" | sha256sum -c
sha256sum -c SHA256SUMS --ignore-missing      # from the trunkjet release (unsigned, see above)
sudo apt-get install ./foundationdb-clients_7.3.77-1_amd64.deb ./trunkjet-server_<version>_amd64.deb
tjetd --version                                # 0.1.0 (commit <40 hex digits>)

The package installs:

PathWhat
/usr/bin/tjetd, tjet-worker, tjet-adminrelease binaries (optimised, debug info stripped, --version names the commit; dirty for a build from a modified tree)
/usr/lib/systemd/system/tjetd.service, tjet-worker.servicehardened units: user tjet, ProtectSystem=strict, NoNewPrivileges, no capabilities, a system call filter, Restart=on-failure, SIGTERM stop
/usr/lib/sysusers.d/trunkjet.conf, /usr/lib/tmpfiles.d/trunkjet.confthe tjet system user; /etc/trunkjet (root:tjet 0750), /var/lib/trunkjet (tjet 0750)
/etc/trunkjet/trunkjet.envshared by both units: cluster file, installation, cell, content store, TJET_S3_*
/etc/trunkjet/tjetd.toml, /etc/trunkjet/tjet-worker.envper-process settings
/etc/trunkjet/secrets/cursor.key32 random bytes, generated on first install (tjet 0600)
/usr/share/doc/trunkjet-server/this page, the OpenAPI contract, annotated examples

The services are not started by the installation. Removing the package stops them and keeps the configuration and /var/lib/trunkjet; purging removes the configuration and the cursor key but never the data (content store, search replicas, archives) or the tjet user.

3. Point it at FoundationDB

sudo install -m 0644 fdb.cluster /etc/foundationdb/fdb.cluster    # from a cluster host
fdbcli -C /etc/foundationdb/fdb.cluster --exec status              # "Healthy", redundancy as planned

Edit /etc/trunkjet/trunkjet.env: choose TJET_INSTALLATION (and TJET_CELL) once; they name the data in FoundationDB and never change. The first process that opens a new installation creates its cell; a process started while the cluster is degraded waits up to TJET_FDB_OPEN_WAIT_SECS (120 s) for it.

4. Content store

  • One host: keep TJET_STORE=local (/var/lib/trunkjet/store). Durability is that of the host's disk (SINGLE_HOST, the doctor warns). Back it up with the host. The units allow writes only below /var/lib/trunkjet (ProtectSystem=strict): a store, search or archive directory elsewhere needs ReadWritePaths= in systemctl edit tjetd (and tjet-worker).
  • Several hosts: TJET_STORE=s3 with TJET_S3_ENDPOINT (https), TJET_S3_REGION, TJET_S3_BUCKET, TJET_S3_ACCESS_KEY, TJET_S3_SECRET_KEY in trunkjet.env (root:tjet 0640). Set TJET_S3_DURABILITY=regional only for a storage contract qualified as such.

5. TLS and identity

As installed, tjetd listens on 127.0.0.1:8640 without TLS (a non-loopback listener without TLS is refused, exit 2). To serve other hosts, either terminate TLS in tjetd:

sudo install -o root -g tjet -m 0640 server.crt /etc/trunkjet/tls/server.crt
sudo install -o tjet -g tjet -m 0600 server.key /etc/trunkjet/tls/server.key

and in /etc/trunkjet/tjetd.toml set listen = "0.0.0.0:8640", tls_cert_file and tls_key_file; or keep the loopback listener behind a TLS reverse proxy on the same host. Secret files that are group- or world-readable are refused. A port below 1024 needs CAP_NET_BIND_SERVICE (systemctl edit tjetd; prefer a proxy).

Interactive login needs an OpenID Connect provider: add an [[oidc]] section (admin guide §4). Without one only existing sessions and scoped tokens authenticate (tjetd logs a warning). Every tjetd of an installation needs the same /etc/trunkjet/secrets/cursor.key: copy the first host's file to the others before starting them.

6. Start and check

sudo systemctl enable --now tjetd tjet-worker
curl -s http://127.0.0.1:9640/healthz          # ok              (liveness)
curl -s http://127.0.0.1:9640/readyz           # {"status":"ready","checks":[...]}
sudo -u tjet sh -c 'set -a; . /etc/trunkjet/trunkjet.env; tjet-admin doctor'
journalctl -u tjetd -u tjet-worker -f

/healthz, /readyz and /metrics are on the private metrics listener (metrics_listen, 127.0.0.1:9640; the worker's metrics on 127.0.0.1:9641), never on the API port.

  • /healthz is liveness: 200 ok while the process answers. It checks no dependency, so a FoundationDB outage never makes an orchestrator restart every server at once.
  • /readyz is readiness: 200 when every check passes, else 503, with a JSON body naming each check: fdb (FoundationDB answers within 5 s and this process still holds the cell's authority epoch; a read-only cell is ready, a fenced process is not), cell_link (the directory entry and cell link agree) and storage (a write/read/delete round trip through the content store within 10 s; one probe at a time). Answers are reused for 2 s, so probes cause at most one check run per 2 s. From SIGTERM on, /readyz answers 503 {"status":"draining"} while tjetd drains (at most 10 s), so load balancers stop sending it requests.

7. First tenant

sudo -u tjet sh -c 'set -a; . /etc/trunkjet/trunkjet.env; \
  tjet-admin --issuer https://login.example.com bootstrap-tenant acme --principal <idp-subject>:tenant_admin'

tjet login scm.example.com then signs that person in (admin guide §4).

8. Backups and monitoring

  • FoundationDB: tjet-admin fdb-backup start (continuous backup of the installation's keys and its cell link; runbook backups and fdb-restore). Repository archives: admin guide §10.

  • Restore drills: the package installs tjet-dr-verify.timer (weekly, not enabled). It restores the latest FoundationDB backup into a separate, empty scratch cluster, checks it against production and the content store, and clears it again. Production is only read.

    1. Create a small FoundationDB cluster used for nothing else (one node is enough). Run a backup_agent on it that can read the backup container. Copy its cluster file to /etc/trunkjet/dr-scratch.cluster (root:tjet 0640).
    2. In /etc/trunkjet/tjet-dr.env, set TJET_DR_BACKUP_TAG to the tag of fdb-backup start.
    3. Run one drill by hand: systemctl start tjet-dr-verify.service, then journalctl -u tjet-dr-verify. The result is in /var/lib/trunkjet/dr/last-verify.json.
    4. systemctl enable --now tjet-dr-verify.timer on one host of the installation.

    tjet-admin doctor warns (dr_drill) when no drill verified a restore within 192 h (TJET_DR_MAX_AGE_HOURS). Point the node exporter's textfile collector at /var/lib/trunkjet-metrics for the tjet_dr_* gauges and the alerts ScmDrDrillStale and ScmDrDrillFailed. Runbook: dr-drill.

  • Scrape 127.0.0.1:9640/metrics and 127.0.0.1:9641/metrics; load the alert rules and the dashboard from deploy/production/observability/. Probe /readyz from the load balancer.

Reference layouts

Two reference layouts for more than one host, failure-tested in Docker on one host (see Tested below for what that covers). Configuration files are in deploy/production/fdb/, deploy/production/multinode/ and deploy/production/lb/.

3-node (default)5-node (next size)
FoundationDB hosts3, one fault zone each5, one fault zone each
Redundancy, coordinatorsdouble, 3 coordinatorstriple, 5 coordinators
Survives1 host down (no redundancy left until it is back)2 hosts down
configure lineconfigure-3-node.fdbcliconfigure-5-node.fdbcli
tjetd3, one on each FoundationDB host2–4 on their own hosts
tjet-worker1, on one of the hosts1–2 on their own hosts
ContentS3 (one bucket)S3 (one bucket)
Load balancerHAProxy (or any L7 balancer with active health checks) on /readyzthe same, with a standby

FoundationDB. The same foundationdb.conf on every FoundationDB host: three processes with their own class (storage on 4500, transaction logs on 4501, stateless roles on 4502), the storage engine ssd, data on a local SSD/NVMe file system, one backup agent. Run the layout's configure line once, then (5-node) coordinators auto, and copy the resulting fdb.cluster to every trunkjet host. fdbcli --exec status must show the planned redundancy and Fault Tolerance of 1 (3-node) or 2 (5-node) machines; tjet-admin doctor reports the same.

tjetd instances. Every instance of an installation shares, and must agree on: trunkjet.env (the FoundationDB cluster file, TJET_INSTALLATION, TJET_CELL, TJET_STORE=s3 with the same bucket), the cursor key /etc/trunkjet/secrets/cursor.key (copy the first host's file; a pagination cursor issued by one instance is opened by whichever instance the next request reaches), the [[oidc]] providers and the release. tjetd.toml differs only in metrics_listen, the host's private address, because the load balancer checks /readyz there. with_worker = false: background duties run in tjet-worker (several may run; their work is idempotent). A local content store cannot serve several hosts.

Load balancer. haproxy.cfg: TLS on the front, balance leastconn, no stickiness, option httpchk GET /readyz on port 9640 with inter 2s fall 2 rise 2 (a stopping tjetd refuses new connections from SIGTERM on; HAProxy sends those to another instance and marks it down), retries only for connections that never reached a server (retry-on conn-failure). The balancer must not replay a request that reached tjetd: trunkjet clients retry those themselves with the same request id, which the server answers once. /readyz checks dependencies every instance shares (FoundationDB, the content store), so during a FoundationDB recovery or a store restart all instances turn unready together: the same servers are listed again as backup ... no-check, so requests still reach tjetd, which answers or refuses them with its own JSON error, instead of the balancer answering every request itself. When no tjetd is reachable at all, the balancer answers with trunkjet JSON errors (errors/: RETRY_LATER, or OUTCOME_UNKNOWN for 502/504), not HTML. The private paths (/metrics, /healthz, /readyz) are refused on the public name. Write safety never depends on readiness: every write commits only while the instance holds the cell's authority epoch (a fenced instance refuses). One gap: the cell link is checked when a process opens the cell and by /readyz, not on every write, so a directory/link change made while instances run (a restore into a live installation, which the fdb-restore runbook forbids: stop every process first) is not refused by running instances that the fallback still reaches.

Tested by make prod-multinode (each scenario also on its own, e.g. make prod-multinode-fdb-node-kill; PROD_MN_NODES=5 for the 5-node layout): the layout in Docker on one host, eight clients saving, sending, reviewing, merging and reading through HAProxy while one FoundationDB node is killed, one tjetd is killed, the worker is killed, the S3 store restarts, one FoundationDB node is cut off the network, and the whole cluster is killed and started again. Afterwards every acknowledged write is read back and checked for duplicates. Results, recovery times and limits: records/evidence/runs/20261125-prod-multinode.

Container image

The same binaries as an image (Debian 13 slim, user 65532; slim rather than distroless because libfdb_c needs liblzma and zlib), built by tools/release/server_package_test.py from //deploy/production/package:image_layer and container/Dockerfile with a digest-pinned base, SOURCE_DATE_EPOCH=0 and rewritten timestamps (two builds give the same digest). It is not published to a registry yet (unsigned, T080).

docker run -d --name tjetd --read-only --tmpfs /tmp \
  -v /srv/trunkjet/etc:/etc/trunkjet:ro -v trunkjet-data:/var/lib/trunkjet \
  -e TJET_FDB_CLUSTER_FILE=/etc/trunkjet/fdb.cluster -e TJET_INSTALLATION=acme \
  -p 8640:8640 -p 127.0.0.1:9640:9640 trunkjet-server:<version>

/etc/trunkjet holds tjetd.toml (with listen = "0.0.0.0:8640", metrics_listen = "0.0.0.0:9640", tls_* and cursor_key_file), the certificate, the key and the cursor key (owned by 65532, mode 0600; in the image /etc/trunkjet is root:65532 0750, so the process cannot rewrite its configuration; mount it read-only). Run tjet-worker from the same image with --entrypoint /usr/bin/tjet-worker and the same environment. docker stop sends SIGTERM: tjetd drains and exits 0. Kubernetes: livenessProbe on /healthz, readinessProbe on /readyz, both on port 9640.

Kubernetes

The same image on Kubernetes: the Helm chart deploy/k8s/chart/trunkjet deploys tjetd (API + web; the image carries the web app) and tjet-worker per cell, FoundationDB through the fdb-kubernetes-operator, Garage or an external S3, ingress for the canonical and alias hosts with cert-manager, Prometheus rules and the Grafana dashboard, FoundationDB backup agents, the weekly DR drill and the runner pools. Hosted infrastructure on Hetzner (k3s, OpenTofu): deploy/hetzner. Steps and operations: runbook kubernetes; what the owner provides: owner checklist.

Client downloads on this server

(The server quickstart is a different script: curl -fsSL https://<your server>/quickstart.sh | sh, Quickstart. Every tjetd serves it from its binary, with no downloads directory.)

Each server can offer the clients itself, so curl -fsSL https://<your server>/install.sh | sh and the /download page install builds you chose. Put the release files into a directory and start tjetd with --downloads-dir DIR (TJET_DOWNLOADS_DIR):

tools/release/stage_downloads.py --out /var/lib/trunkjet/downloads \
  target/dist/trunkjet-client-<version>-x86_64-unknown-linux-gnu.tar.gz \
  target/dist/trunkjet-cli_<version>_amd64.deb \
  trunkjet-<version>-windows-x64.msi trunkjet-<version>-macos-universal.pkg

It copies the files and writes SHA256SUMS. tjetd serves only the files listed there, at /downloads/<name>, plus /downloads/release.json for the page and /install.sh, /install.ps1 with the server's own address filled in (TJET_PUBLIC_ORIGIN, or the request's host). Without a downloads directory these answer 404 and /download points at trunkjet.io. The files are for signed-in users only until you set TJET_DOWNLOADS_PUBLIC=1 (Helm: downloads.public): publishing the binaries is your launch decision. While it is off, signed-out visitors read "Public downloads open at launch", and a script sends its token with TJET_TOKEN. Once public, put a cache or CDN in front if many people download at once. With the Helm chart, downloads.enabled runs the downloads image (deploy/downloads) as an init container that copies the files in; tools/release/stage_client_downloads.sh builds the Linux x86-64 and arm64 files, and the macOS .pkg and Windows .msi of the native-host pipeline are passed as further arguments, so the page offers a system only when its file is there. A channels.json beside them names published Homebrew, winget and apt channels (see tools/release/distribution/); the page shows a channel only when it is named there. Installing the clients themselves: Install the CLI and the desktop app.