This is the Operations section of the LinkJar PDS documentation, as Markdown. # Environment variables > Every setting a self-hoster is likely to touch, grouped by what it does, with the reference server's defaults. [Source](https://pds.linkjar.io/configure/environment/) The server reads configuration from its process environment. Compose loads `pds.env`; native systemd examples load `/etc/linkjar-pds/pds.env`. The binary does not load either file itself. It uses the reference server’s variable names. The tables identify LinkJar defaults and safety restrictions; new settings are at the end. An invalid value stops the server at start with a message that names the variable. An unknown `PDS_*` variable is a warning. `check-config` runs the same checks without starting anything: For native services, use the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services): ```bash pds check-config ``` For Compose: ```bash docker compose run --rm pds linkjar-pds check-config ``` ## The server | Variable | Meaning | Default | | ---------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------ | | `PDS_HOSTNAME` | The server’s public name. **Required.** | | | `PDS_PORT` | The port the public listener binds. | `2583` natively; `3000` in the image | | `PDS_SERVICE_DID` | The server’s own DID. | `did:web:` and the hostname | | `PDS_SERVICE_HANDLE_DOMAINS` | The suffixes of hosted handles, each with a leading dot, separated by commas. | `.` and the hostname | | `PDS_VERSION` | Shown by the health route. | unset | | `PDS_CONTACT_EMAIL_ADDRESS` | Shown by `describeServer`. | unset | | `PDS_PRIVACY_POLICY_URL`, `PDS_TERMS_OF_SERVICE_URL` | Linked by `describeServer` and on the sign-up page. | unset | | `PDS_HOME_URL`, `PDS_SUPPORT_URL` | Links on the OAuth pages. | unset | | `PDS_DEV_MODE` | Relaxes checks for local development. Never on a public host. | `false` | ## Secrets | Variable | Meaning | | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `PDS_JWT_SECRET` | Signs sessions. **Required.** Changing it signs everyone out. | | `PDS_ADMIN_PASSWORD` | The password of the `admin` user for the admin API and invite codes. **Required.** | | `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | The key that signs PLC operations for new accounts and handle changes. Without it the server creates no account. Keep it: it is the control of every account’s DID. | | `PDS_DPOP_SECRET` | Signs the nonces of OAuth proofs. Optional; set it so that nonces survive a restart. | | `PDS_RECOVERY_DID_KEY` | A `did:key` added to each new account’s DID document as a further rotation key, for recovery with a key kept elsewhere. Optional. | ## Storage | Variable | Meaning | Default | | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------- | | `PDS_DATA_DIRECTORY` | The data directory. Native examples use `/var/lib/linkjar-pds`; Compose mounts it at `/app/data`. | | | `PDS_BLOBSTORE_DISK_LOCATION` | Where blobs go on disk, usually `blocks` under the data directory. | | | `PDS_BLOBSTORE_S3_*` | An S3-compatible store in place of the disk. [Blob storage](https://pds.linkjar.io/configure/blob-storage/) has the list. | | | `PDS_BLOB_UPLOAD_LIMIT` | The largest blob, in bytes. The example file sets 100 MiB. | 5 MiB | | `PDS_ACTOR_STORE_CACHE_SIZE` | How many accounts’ databases stay open at once. | `100` | | `PDS_MAX_REPO_IMPORT_SIZE` | The largest repository import body, in bytes. Must be positive; parsing uses additional memory. | 64 MiB (67,108,864 bytes) | | `PDS_ACCEPTING_REPO_IMPORTS` | Whether accounts may import a repository, as in a migration from another server. | `true` | | `PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT` | Hands SQLite checkpoints to a backup tool such as Litestream. | `false` | ## Identity | Variable | Meaning | Default | | -------------------------------------------------- | --------------------------------------------------------------------------- | ----------------------- | | `PDS_DID_PLC_URL` | The PLC directory where new DIDs are registered. | `https://plc.directory` | | `PDS_HANDLE_BACKUP_NAMESERVERS` | Nameservers to ask when the system resolver cannot verify a handle. | unset | | `PDS_ID_RESOLVER_TIMEOUT` | How long a handle or DID lookup may take, in milliseconds. | `3000` | | `PDS_DID_CACHE_STALE_TTL`, `PDS_DID_CACHE_MAX_TTL` | How long a cached DID document is served before and after a refresh is due. | 1 hour, 1 day | ## The network | Variable | Meaning | Usual value | | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | | `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID` | The AppView that serves feeds, notifications and preferences for the Bluesky app. Without them the app cannot load its settings. | `https://api.bsky.app`, `did:web:api.bsky.app` | | `PDS_REPORT_SERVICE_URL`, `PDS_REPORT_SERVICE_DID` | Where `createReport` is forwarded. | `https://mod.bsky.app`, `did:plc:ar7c4by46qjdydhdevvrndac` | | `PDS_CRAWLERS` | The relays the server asks to crawl it, separated by commas. | `https://bsky.network` | | `PDS_MAX_SUBSCRIPTION_BUFFER` | How many events a slow firehose subscriber may fall behind before the server drops it. | `500` | | `PDS_REPO_BACKFILL_LIMIT_MS` | How far back a firehose subscriber may ask for events, in milliseconds. | 3 days | | `PDS_PROXY_HEADERS_TIMEOUT` | Total upstream proxy deadline, including the response body, in milliseconds. | `10000` | | `PDS_DISABLE_SSRF_PROTECTION` | Allows private OAuth metadata destinations only with `PDS_DEV_MODE=true`. Production startup rejects it. | `false` | Untrusted DID, proxy, handle and client-metadata destinations must use public HTTPS on port 443. The connector checks the actual destination addresses, refuses redirects and ignores environment proxies. Configured service URLs, including PLC and AppView, remain trusted and can use private networks. Keep development mode off on a public host. Response caps are fixed per operation: DID/PLC 512 KiB, OAuth metadata 256 KiB, MCP metadata 64 KiB, external handle files 4 KiB, and proxy errors 64 KiB. `PDS_FETCH_MAX_RESPONSE_SIZE` is not an implemented setting. ## Invites and limits | Variable | Meaning | Default | | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------- | | `PDS_INVITE_REQUIRED` | Whether sign-up needs an invite code. | `true` in the example file | | `PDS_INVITE_EPOCH`, `PDS_INVITE_INTERVAL` | The reference server’s per-account invites: from the epoch on, each account earns one code per interval, in milliseconds. | unset, no codes earned | | `PDS_RATE_LIMITS_ENABLED` | The reference server’s rate limits, by client address and by account. | `true` | | `PDS_RATE_LIMIT_BYPASS_KEY`, `PDS_RATE_LIMIT_BYPASS_IPS` | A header value, and addresses, that bypass the limits. | unset | | `PDS_HCAPTCHA_SITE_KEY`, `PDS_HCAPTCHA_SECRET_KEY`, `PDS_HCAPTCHA_TOKEN_SALT` | hCaptcha on the sign-up page. All three or none. | unset | The process also admits at most 8 uploads, 2 imports, 8 streamed exports, 32 firehose connections and 64 ordinary blocking jobs. Exhaustion returns 503 `ServerBusy`; a rate-limit bypass does not bypass these limits. Audit writes use four separate workers and wait for capacity. These limits are fixed in the implementation. Request-body reads allow 15 seconds without progress and 300 seconds total; expiry returns 408 `RequestTimeout`. Exports have the same total deadline and a 15-second queue stall limit. Firehose sends may stall for 15 seconds; incoming frames and messages are capped at 64 KiB. Clients must discard an incomplete export and retry later. Refused bodies are drained for at most five seconds or the byte cap; an oversized body still returns 413 if draining times out. ## Mail | Variable | Meaning | | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `PDS_EMAIL_SMTP_URL` | The SMTP server, as a URL with the credentials. [Email](https://pds.linkjar.io/configure/email/) has the shape. | | `PDS_EMAIL_FROM_ADDRESS` | The sender of the server’s mail. | | `PDS_MODERATION_EMAIL_SMTP_URL`, `PDS_MODERATION_EMAIL_ADDRESS` | The sender of mail a moderation service sends to accounts through the admin API. Optional. | ## Branding `PDS_LOGO_URL`, `PDS_PRIMARY_COLOR`, `PDS_ERROR_COLOR`, `PDS_WARNING_COLOR`, `PDS_SUCCESS_COLOR`, `PDS_INFO_COLOR`, `PDS_BACKGROUND_LIGHT_URL` and `PDS_BACKGROUND_DARK_URL` style the sign-in and sign-up pages, as on the reference server. ## New in LinkJar PDS | Variable | Meaning | Default | | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | | `PDS_PROFILE` | `stock` for the reference server’s behaviour, `linkjar` for LinkJar’s sign-in providers and policies. [Profiles](https://pds.linkjar.io/configure/profiles/). | `stock` | | `PDS_METRICS_ADDRESS` | The private listener for Prometheus metrics. [Logs, health and metrics](https://pds.linkjar.io/operate/monitoring/). | unset, no listener | | `PDS_OPS_ADDRESS`, `PDS_OPS_CLIENT_IDS` | The private listener of the operations console, and the console’s client id. [Console and MCP server](https://pds.linkjar.io/scale/sidecars/). | unset | | `PDS_AUDIT_KEY_ED25519_PRIVATE_KEY_HEX` | The key that signs audit checkpoints. [Audit log](https://pds.linkjar.io/operate/audit-log/). | unset, checkpoints unsigned | | `PDS_AUDIT_CHECKPOINT_REPO` | The DID of the account on this server that publishes the checkpoints. | unset | | `PDS_POSTGRES_URL`, `PDS_POSTGRES_SCHEMA_PREFIX` | The shared databases on Postgres instead of SQLite files. [Postgres](https://pds.linkjar.io/scale/postgres/). | unset, `pds` | | `PDS_ENTRYWAY_*`, `PDS_MEMBER_*` | A member host, or an entryway. [Entryway](https://pds.linkjar.io/scale/entryway/). | unset | | `PDS_MCP_CLIENT_IDS`, `PDS_OAUTH_KNOWN_CLIENTS_FILE` | The MCP servers of this server, and OAuth clients known without a fetch. | unset | | `LOG_LEVEL` | The log filter: `info`, `debug`, or a filter such as `info,pds_xrpc=debug`. | `info` | The [specification’s Appendix C](https://github.com/linkjar/pds/blob/main/docs/SPEC.md#appendix-c-configuration) lists every accepted variable, including the ones this page leaves out. # Accounts, invites and moderation > The admin API with the admin password: invite codes, account details, password and email changes, takedowns and deletion. [Source](https://pds.linkjar.io/operate/accounts/) The admin API is the reference server’s. Every call authenticates with HTTP basic auth as `admin` with `PDS_ADMIN_PASSWORD`, and every call is an entry in the [audit log](https://pds.linkjar.io/operate/audit-log/). The commands below assume `PDS_ADMIN_PASSWORD` in the environment: ```bash read -s PDS_ADMIN_PASSWORD && export PDS_ADMIN_PASSWORD ``` ## Invite codes One code for one account: ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"useCount": 1}' https://pds.example.com/xrpc/com.atproto.server.createInviteCode ``` Ten codes of five uses each: ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"codeCount": 10, "useCount": 5}' https://pds.example.com/xrpc/com.atproto.server.createInviteCodes ``` Disable a code that leaked: ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"codes": ["pds-example-com-xxxxx-xxxxx"]}' https://pds.example.com/xrpc/com.atproto.admin.disableInviteCodes ``` `PDS_INVITE_REQUIRED=false` opens sign-up to everyone. Leave it on unless you want a public server, and then set up hCaptcha and watch the sign-ups. ## Look up an account ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" "https://pds.example.com/xrpc/com.atproto.admin.getAccountInfo?did=did:plc:…" ``` The answer has the handle, the email address and whether it is confirmed, the invite code the account used, and the codes it has. ## Reset a password or change an address ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"did": "did:plc:…", "password": "…"}' https://pds.example.com/xrpc/com.atproto.admin.updateAccountPassword ``` ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"account": "did:plc:…", "email": "alice@example.net"}' https://pds.example.com/xrpc/com.atproto.admin.updateAccountEmail ``` A person who still has access resets their own password from the app, through [email](https://pds.linkjar.io/configure/email/). Both password reset and admin password update revoke the account’s legacy and OAuth sessions, remembered sign-ins, client grants, pending authorizations, app passwords and outstanding email tokens. The person must sign in again and create replacement app passwords. Member hosts check the entryway on each authenticated request, so recovery takes effect on the next request there too. Recovery state is part of the account database. Preserve it in [backups](https://pds.linkjar.io/operate/backup/), and check the [rollback limits](https://pds.linkjar.io/operate/update/#roll-back) before using an older build. ## Take an account down A takedown hides the repository and quarantines its blobs. The account cannot sign in; its data stays until you lift the takedown or delete the account. ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"subject": {"$type": "com.atproto.admin.defs#repoRef", "did": "did:plc:…"}, "takedown": {"applied": true, "ref": "spam"}}' https://pds.example.com/xrpc/com.atproto.admin.updateSubjectStatus ``` Lift it with `"applied": false`. The same method takes down one record, with a `com.atproto.repo.strongRef` subject, or one blob. ## Delete an account ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"did": "did:plc:…"}' https://pds.example.com/xrpc/com.atproto.admin.deleteAccount ``` The repository, the blobs and the sessions are removed. The DID stays in the PLC directory, as every DID does; the account can move to another server later with the same DID. A person deletes their own account from the app, with a token sent by mail. ## Reports A report from the app goes to the moderation service named by `PDS_REPORT_SERVICE_URL`, Bluesky’s by default. The server keeps no report queue of its own. ## A console The [operations console](https://pds.linkjar.io/scale/sidecars/) does the above from a page, with a reason recorded for each action, and shows the live firehose subscribers and the audit log. # Audit log > What the server records about accounts and operators, how checkpoints make the record tamper-evident, and how to verify a bundle offline. [Source](https://pds.linkjar.io/operate/audit-log/) Every action on an account or by an operator is an entry in a log the server cannot rewrite without it showing: a sign-up, a password or email change, a handle change, a deactivation, a deletion, a takedown, an invite created or disabled, and every call to the admin API, with its outcome. Ordinary reads and ordinary writes to a repository are not in it: repository data is already signed, and reads are a traffic log. Each entry carries the hash of the one before it, and the store refuses updates and deletes. Every five minutes, and at shutdown, the server builds a Merkle tree over the new entries and signs a checkpoint over its root. A checkpoint published into an account’s repository travels the firehose, so a copy exists outside the host. ## Turn on signing Without a key the log chains its entries and signs nothing. Create a key, 32 random bytes as 64 hexadecimal digits: ```bash openssl rand -hex 32 ``` In the runtime environment file: ```dotenv PDS_AUDIT_KEY_ED25519_PRIVATE_KEY_HEX=… PDS_AUDIT_CHECKPOINT_REPO=did:plc:… ``` The repository is your own account on the server. Each checkpoint becomes a record in it, under `io.linkjar.pds.audit.checkpoint`. Without `PDS_AUDIT_CHECKPOINT_REPO` the checkpoints stay in `audit.sqlite`, and nobody outside can compare them. A key that differs from the one of the last checkpoint is itself logged before it signs, so a key change is visible in the record. ## Seal history A data directory that existed before the log, one the reference server wrote, has history the log did not see. Seal it once, before the first start of the server on it: For native services, stop `linkjar-pds` and use the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services): ```bash pds audit seal ``` For Compose, stop the main container first: ```bash docker compose run --rm pds linkjar-pds audit seal ``` It prints `sealed accounts as sha256:…` and `signed by ed25519:…`. Keep both lines. The command is refused on a log that has entries. ## Export and verify For native services: ```bash umask 077 pds audit export > audit-bundle.json ``` For Compose: ```bash umask 077 docker compose exec -T pds linkjar-pds audit export > audit-bundle.json ``` The bundle holds the entries, the chain hashes, the inclusion proofs, the checkpoints that cover them and the public keys. Verify it away from the host, with any build of the binary: ```bash linkjar-pds audit verify audit-bundle.json ``` It recomputes the chain, the trees and the signatures and exits 0, or names the first entry that does not fit and exits 1. The verifier shares nothing with the writer but the entry format. ## Watch it Two metrics say whether signing works: `pds_audit_unsigned_entries` returns to 0 within five minutes of an entry, and `pds_audit_checkpoint_age_seconds` stays under 600 while there are unsigned entries. [Logs, health and metrics](https://pds.linkjar.io/operate/monitoring/) has the listener. # Back up and restore > Back up native and Docker installations, preserve authentication state, and restore with the correct paths and service user. [Source](https://pds.linkjar.io/operate/backup/) Keep the complete data directory, all blobs, configuration, and every secret. The Compose deployment uses `data/` and `pds.env`. The native examples use `/var/lib/linkjar-pds` and `/etc/linkjar-pds/pds.env`. Include any storage or key files configured outside those paths, and record the exact source commit or image digest. With S3 or Postgres, back up those stores at the same consistent point too; a local archive cannot include remote data. The PLC rotation key controls the accounts’ DIDs. The JWT secret signs sessions. For secrets provisioned under `/run/secrets`, preserve their encrypted source and recovery keys so you can reconstruct the runtime file on a fresh host. ## The data directory | Path | Content | Keep | | -------------------------------- | ------------------------------------------------------------------------------- | --------------- | | `account.sqlite` | accounts, passwords, sessions, invites, OAuth state, credential recovery epochs | yes | | `sequencer.sqlite` | the event log the firehose serves | yes | | `did_cache.sqlite` | cached DID documents | no, rebuilt | | `audit.sqlite` | the [audit log](https://pds.linkjar.io/operate/audit-log/) | yes | | `ops.sqlite` | commits in flight, operator roles, blocked domains | yes | | `actors///store.sqlite` | an account’s repository, records and blob index | yes | | `actors///key` | the account’s signing key | yes | | `actors/reserved_keys/` | signing keys of sign-ups in progress | no | | `blocks//` | blobs | yes | | `tempt/`, `quarantine/` | uploads in progress; blobs of taken-down accounts | quarantine, yes | | `linkjar-pds.lock` | held by the running server | no | SQLite can keep recent writes in `-wal` files while the server runs. Copying live database, WAL, and SHM files individually does not ensure a consistent backup. Use a cold backup, a coordinated filesystem snapshot, or a supported SQLite backup tool. Do not omit WAL files from a snapshot. Keep the whole account database, including its `credential_epoch` table. That table prevents tokens issued before password recovery from working again. A restore of an older backup also restores its older credentials, sessions and recovery state. If those credentials were compromised, repeat recovery before reopening the server. On [Postgres](https://pds.linkjar.io/scale/postgres/), the table is part of the account schema. ## A cold backup Stop the server, archive its state and configuration, then start it. The TLS proxy can return an upstream error during the pause. Keep the server stopped until the archive has completed successfully. ### Native and NixOS examples For the paths in [native installation](https://pds.linkjar.io/start/native/): ```bash sudo systemctl stop linkjar-pds && sudo sh -c 'umask 077; tar -czf /root/linkjar-pds-backup-$(date +%F-%H%M%S).tar.gz -C / var/lib/linkjar-pds etc/linkjar-pds' && sudo systemctl start linkjar-pds ``` The archive is root-readable only and contains the data plus the runtime file under `/etc/linkjar-pds`. If you use another secret path, also back up its recoverable source. Preserve the host flake and lockfile or the systemd unit, TLS proxy configuration, and deployment record. Keep a recoverable copy of the selected binary or its pinned build inputs. ### Docker Compose From the directory containing `compose.yml`: ```bash docker compose stop pds && sudo sh -c 'umask 077; tar -czf /root/linkjar-pds-backup-$(date +%F-%H%M%S).tar.gz data pds.env .env compose.yml Caddyfile' && docker compose start pds ``` Move the archive to protected storage off the host. Encrypt backups and restrict access: they contain account data, passwords, signing keys, and session state. Rehearse a restore before relying on them. ## Continuous replication LinkJar’s own hosts replicate the SQLite files with [Litestream](https://litestream.io/) to object storage and sync the blobs beside them. With Litestream in charge of checkpoints, set `PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT=true`. Rehearse the restore before you rely on it. ## One account `export-car` writes an account’s repository as a CAR file, the format every AT Protocol tool reads and the one an account takes to another server. For native services, use the [command helper](https://pds.linkjar.io/operate/cli/#native-services): ```bash umask 077 pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > alice.car ``` For Docker: ```bash umask 077 docker compose exec -T pds linkjar-pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > alice.car ``` Blobs are not in the CAR; they are the files under `blocks//`. ## Restore Restore on a private host with the PDS service stopped. Install the reviewed build and create its service user before restoring data. Inspect the archive paths, restore them to their intended locations, and keep the secret file restricted to root. Restore external blobs and databases consistently too. ### Native or NixOS Restore the native data to `/var/lib/linkjar-pds` and the runtime file to `/etc/linkjar-pds/pds.env`, or reconstruct it through your secret manager. Do not start an empty NixOS service against the public hostname during recovery. After restoring, check ownership and run the [native helper](https://pds.linkjar.io/operate/cli/#native-services): ```bash sudo chown -R linkjar-pds:linkjar-pds /var/lib/linkjar-pds sudo chmod 0700 /var/lib/linkjar-pds sudo chmod 0600 /etc/linkjar-pds/pds.env pds check-config pds verify ``` Keep native paths in the environment. A restore from Docker needs `/app/data` paths changed to their host equivalents. Do not generate new account secrets. ### Docker Compose Unpack the Compose backup into its deployment directory. Give the restored data to the container’s user and check it before starting: ```bash sudo chown -R 1000:1000 data docker compose run --rm pds linkjar-pds verify ``` For either installation, `verify` reads every repository and compares its records and blobs. Expect `differences 0`. Resolve differences before reopening traffic. Start the selected service, move DNS if needed, and [check it from outside](https://pds.linkjar.io/start/verify/). The relay resumes at its cursor. A restore from a backup older than the last events the relay saw leaves the relay ahead of the server; the relay then re-crawls the repositories at their next commit. > **One server per data directory** > > Never run two servers on one data directory, on one host or two. The server takes `linkjar-pds.lock` at start and refuses to start when another holds it, but a copy on a second host has its own lock file. # Command line > Run operator commands with a native binary, the NixOS service, or Docker Compose. [Source](https://pds.linkjar.io/operate/cli/) Every installation uses the same `linkjar-pds` executable and commands. Except for `version`, `help`, and `audit verify`, commands read configuration from the environment. The binary does not automatically load `pds.env`. Use the same data paths, secrets, and service user as the server. ## Native services The [native installation](https://pds.linkjar.io/start/native/) uses the `linkjar-pds` user, `/var/lib/linkjar-pds`, port `2583`, and `/etc/linkjar-pds/pds.env`. Systemd can load that root-owned file before switching to the service user. Define this shell helper on the host: ```bash PDS_BIN=/usr/local/bin/linkjar-pds pds() { sudo systemd-run --quiet --wait --pipe --collect \ --property=Type=exec \ --property=User=linkjar-pds \ --property=Group=linkjar-pds \ --property=WorkingDirectory=/var/lib/linkjar-pds \ --property=EnvironmentFile=/etc/linkjar-pds/pds.env \ --property=UMask=0077 \ --setenv=PDS_DATA_DIRECTORY=/var/lib/linkjar-pds \ --setenv=PDS_PORT=2583 \ "$PDS_BIN" "$@" } ``` For the NixOS example, set `PDS_BIN=/run/current-system/sw/bin/linkjar-pds` instead. It installs the same package used by the service on that path. If you changed the runtime file, data path, or port, change the helper too. If public settings live in `services.linkjar-pds.environment`, also pass them with `--setenv=NAME=value`. Use an explicit `SSL_CERT_FILE` when the host’s CA bundle is in a nonstandard location. This helper uses a temporary service for each command. It waits for completion, returns the command’s exit status, and passes its output to your terminal. It does not start or stop the main PDS service. See the [systemd-run manual](https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html) for these options. ```bash pds check-config pds verify --json ``` Do not run a second `serve` through this helper. Stop the main service before `audit seal` or `migrate-storage`. Run commands that write state as the service user so they do not leave root-owned database files. For a foreground installation, use `linkjar-pds ` directly from the shell that holds its configuration and has access to its data. ## Docker Compose Compose supplies the environment from `pds.env`. Against the running container: ```bash docker compose exec pds linkjar-pds verify ``` With the main server stopped, run a command in a separate container: ```bash docker compose run --rm pds linkjar-pds check-config ``` The configuration check can also run while the server is up. Storage migration and the initial audit seal require the main server to be stopped. ## Commands | Command | Does | | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `serve` | Serves the data directory. Run under your service manager. | | `check-config` | Validates the configuration and exits. Prints `the configuration is valid`. | | `verify [--json]` | Checks the data directory: each repository against its records and blobs. Reads only; prints a summary with the count of differences, lists each, and exits 1 when there is one. | | `export-car ` | Writes one repository to standard output as a CAR file. | | `audit seal` | Begins the audit log with a signed snapshot of the accounts, for a directory with history before the log. Refused on a log with entries. | | `audit export [ []]` | Writes the audit log, or a range of entries, to standard output as a bundle. | | `audit verify ` | Checks a bundle offline. Needs no configuration, so it runs on any machine with the binary. Exits 1 on a problem. | | `migrate-storage --to postgres\|sqlite` | Copies the shared databases between the files of the data directory and Postgres, and compares the two. Runs only while no server does. | | `reconcile [--remove-orphans]` | At an entryway, compares the accounts with the repositories of the member host. | | `health` | Asks the server on this host for its health route. Also used by the container health check. | | `version` | Prints the version. | Standard output belongs to the result; logs go to standard error. For native services, redirect the helper’s output directly: ```bash umask 077 pds audit export > audit-bundle.json pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > account.car ``` For Docker, use `exec -T` so it allocates no terminal: ```bash umask 077 docker compose exec -T pds linkjar-pds audit export > audit-bundle.json ``` # Migrate from the reference PDS > Plan a switch from the reference PDS using the existing data directory, with backup and rollback safeguards. [Source](https://pds.linkjar.io/operate/migrate-from-reference/) LinkJar PDS can serve a data directory the reference server wrote, with the existing `pds.env`. Check a restored copy before switching the running server. Database compatibility alone does not make an older image a safe rollback target. This page assumes the reference server’s installer: the data at `/pds`, the settings in `/pds/pds.env`, and a systemd unit named `pds` that runs its Compose file. This procedure switches the reference Docker deployment to LinkJar’s Compose stack. To run without Docker, also follow the [native cutover steps](https://pds.linkjar.io/start/native/#move-from-docker). Preserve the original data and secrets, adapt host paths and ownership, and run verification with the selected native build before starting it. ## Before the switch 1. Take a [cold backup](https://pds.linkjar.io/operate/backup/#a-cold-backup) of `/pds`. 2. Get the Compose files onto the host, as in [the install](https://pds.linkjar.io/start/install/), and write `.env` with the image and `PDS_DATA_PATH=/pds`. 3. Make `pds.env` from the reference server’s: ```bash sudo cp /pds/pds.env pds.env && sudo chown $USER pds.env && chmod 600 pds.env ``` Change the two paths to where the Compose file mounts the directory: ```ini PDS_DATA_DIRECTORY=/app/data PDS_BLOBSTORE_DISK_LOCATION=/app/data/blocks ``` Leave every other line as it is. The JWT secret, the rotation key, the admin password and the SMTP settings must stay: sessions and the DIDs of the accounts depend on them. 4. Check the configuration: ```bash docker compose run --rm pds linkjar-pds check-config ``` ## The switch 1. Stop the reference server. Two servers must never serve one data directory. ```bash sudo systemctl disable --now pds ``` 2. Check the data directory. `verify` reads every account and prints a summary that ends with `differences 0`: ```bash docker compose run --rm pds linkjar-pds verify ``` A difference is a fact about the data, not about the switch. Stop here and start the reference server again until you understand it. 3. Seal the history for the [audit log](https://pds.linkjar.io/operate/audit-log/#seal-history), if you have set its key: ```bash docker compose run --rm pds linkjar-pds audit seal ``` 4. Start. ```bash docker compose up -d ``` Caddy starts with an empty certificate store and fetches a certificate for the server’s name at once, and for each handle at its first request. 5. [Check it from outside](https://pds.linkjar.io/start/verify/). The relay resumes at its cursor; its status for the host goes back to `active` with the first write. ## Plan for rollback Prefer a forward fix or a validated build that retains LinkJar’s recovery checks. This release adds a `credential_epoch` table to the shared account database and a blob-reference index to actor databases. The reference migration ledger stays unchanged, and older servers can read the layout. The reference server and older LinkJar images do not enforce credential epochs or the member host’s live session check. They can accept revoked, unexpired legacy tokens after password recovery. Read the [update and rollback guidance](https://pds.linkjar.io/operate/update/#roll-back) before choosing an older image. Keep the current account database and `credential_epoch` in backups and copies. Do not restore a pre-recovery account database to undo the switch: that can restore old passwords, credentials, and access. Preserve `audit.sqlite` and `ops.sqlite` as well. > **The relay and the AppView** > > The reference server’s `pds.env` already names `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID` and `PDS_CRAWLERS`. Keep them: without the AppView the Bluesky app cannot load an account’s settings on either server. # Logs, health and metrics > What the server logs, the health route, the metrics listener, and what to alert on. [Source](https://pds.linkjar.io/operate/monitoring/) ## Logs The server logs JSON lines to standard error, one object per line with the time, the level, the message and the fields of the event. Requests carry a request id. The logs never contain a token, a password, an email address or the body of a record. For NixOS and the native systemd service: ```bash sudo journalctl -u linkjar-pds -f -o cat ``` For Compose: ```bash docker compose logs -f pds ``` A foreground binary writes the same JSON to its standard error. Capture it through your service manager rather than discarding it. `LOG_LEVEL` sets the filter: `info` by default, `debug` for everything, or a filter by crate such as `info,pds_oauth=debug`. It takes effect at the next start. ## Health ```bash curl -s https://pds.example.com/xrpc/_health ``` Status 200 when the account database answers; 503 with `"error":"Service Unavailable"` when it does not. The container’s health check runs `linkjar-pds health` every ten seconds against the same route, and Caddy waits for the first pass before it starts. ```bash docker compose ps ``` The `pds` service shows `(healthy)`. For native services: ```bash sudo systemctl status linkjar-pds curl --fail http://127.0.0.1:2583/xrpc/_health ``` A running process alone does not establish health. Monitor the HTTP response; there is no container health scheduler in a native installation. ## Metrics `PDS_METRICS_ADDRESS` starts a private listener in Prometheus text format. Keep it private and outside the public proxy routes. For a native service, bind directly to loopback in its runtime environment: ```dotenv PDS_METRICS_ADDRESS=127.0.0.1:9464 ``` For Compose only, bind inside the container and publish on host loopback. In `pds.env`: ```dotenv PDS_METRICS_ADDRESS=0.0.0.0:9464 ``` In `compose.yml`, under the `pds` service: ```yaml ports: - "127.0.0.1:9464:9464" ``` Then: ```bash curl -s http://127.0.0.1:9464/metrics ``` | Metric | What it is | | ------------------------------------------ | ------------------------------------------------ | | `pds_build_info` | the version, as a label | | `pds_http_requests_total{route,status}` | requests by method and status | | `pds_http_request_duration_seconds{route}` | a histogram of latency by method | | `pds_firehose_subscribers` | open firehose connections | | `pds_audit_entries` | entries in the audit log | | `pds_audit_unsigned_entries` | entries not yet under a signed checkpoint | | `pds_audit_checkpoint_age_seconds` | time since the last checkpoint | | `pds_notice_outbox_depth` | mail waiting to go out, in the `linkjar` profile | A `route` label is a method the server handles, a path it knows, `proxied` or `other`, so a client cannot make up a label. ## What to alert on | Signal | Means | | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | `pds_http_requests_total{status=~"5.."}` rising | the server fails requests; read the logs | | the 99th percentile of `pds_http_request_duration_seconds` | the host is short of CPU or disk, or a client is heavy | | `pds_audit_unsigned_entries` above 0 for more than ten minutes | checkpoints stopped; the key is missing or the clock is off | | `pds_notice_outbox_depth` growing | SMTP fails | | `pds_firehose_subscribers` at 0 for long | the relay is not connected; see [the first account](https://pds.linkjar.io/start/first-account/#when-posts-reach-other-people) | ## Rate limits The reference server’s limits run by default: by client address for requests overall and for sign-ups and sign-ins, and by account for writes. Every answer carries `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`; a refused request is a 429 with `Retry-After`. The server uses the connection address and forwarding from private proxy hops. The supplied Caddy setups forward the client address. Keep the upstream HTTP listener private so public clients cannot bypass the proxy. # Update > Update a pinned native binary, NixOS package, or container image, and understand rollback limits. [Source](https://pds.linkjar.io/operate/update/) An update replaces the executable and restarts the service on the existing data. Record the current build, keep its configuration and secrets, and take a tested [backup](https://pds.linkjar.io/operate/backup/) first. Build or download the replacement before stopping the server. Review changes between the two source commits. This release adds a credential recovery table to the account database and an index to actor databases on writable open. The first index build takes a SQLite write lock and extra disk space. Allow for that work in your maintenance window. ## Native binary [Download and verify](https://pds.linkjar.io/start/builds/#download-a-portable-linux-build) a new archive, or build the selected source revision. Keep the old executable in its versioned `/opt/linkjar-pds/` directory. Install the new executable under a new commit directory before changing the symlink. Stop the service, then select the new executable. Set `PDS_REV` to the full reviewed commit whose binary you installed: ```bash sudo systemctl stop linkjar-pds sudo ln -sfn "/opt/linkjar-pds/$PDS_REV/linkjar-pds" /usr/local/bin/linkjar-pds ``` Use the [native command helper](https://pds.linkjar.io/operate/cli/#native-services), with `PDS_BIN=/usr/local/bin/linkjar-pds`, to check configuration and data before startup: ```bash pds check-config pds verify sudo systemctl start linkjar-pds ``` A failed check leaves the server stopped. Fix the problem before reopening it. A Cargo build needs its compatible host libraries. A normal Nix package needs its store closure and a retained garbage-collection root. The static Linux binary needs the host’s CA bundle. Keep the build type consistent unless you have tested a change, including throughput on your workload. ## NixOS Change the `linkjar-pds` input URL in your host flake to the full reviewed commit. Update only that input in the host’s lockfile: ```bash nix flake update linkjar-pds ``` Review the host flake and lockfile diff, then build the host configuration with your usual `nixos-rebuild build --flake ...` command. Take the backup and activate the reviewed configuration with `nixos-rebuild switch --flake ...`. Use your actual host flake target in place of `...`. The module validates configuration before starting the service. Keep the runtime environment file available through activation. NixOS generations record the package; they do not snapshot the PDS data or runtime secrets. See the [Nix input update reference](https://nix.dev/manual/nix/2.28/command-ref/new-cli/nix3-flake-update.html) for updating a single input. ## Docker Compose Resolve the image tag to its immutable digest: ```bash docker buildx imagetools inspect ghcr.io/linkjar/pds-server:main --format '{{.Manifest.Digest}}' ``` Or [build it yourself](https://pds.linkjar.io/start/install/#choose-the-image). Set `PDS_IMAGE` in `.env` to the new digest, then: ```bash docker compose pull docker compose up -d ``` Compose replaces the server container and leaves Caddy running. Pin a digest; `:main` moves with every merge and cannot identify an exact rollback build. ## Verify the update For NixOS or a native systemd service: ```bash sudo systemctl status linkjar-pds sudo journalctl -u linkjar-pds --since '2 minutes ago' --no-pager ``` For Docker: ```bash docker compose ps docker compose logs --since 2m pds ``` From outside the host, check HTTPS and the server metadata as in [setup verification](https://pds.linkjar.io/start/verify/). Also test sign-in and a representative read: ```bash curl --fail https://pds.example.com/xrpc/_health ``` On `SIGTERM`, the server stops taking connections, finishes writes in flight, closes the firehose so the relay can resume at its cursor, and exits. The supplied native services allow 30 seconds; Compose allows 60 seconds. ## Roll back For a native binary, stop the service, point `/usr/local/bin/linkjar-pds` back to the retained executable, check it, and start. For NixOS, activate the previous reviewed host configuration or generation. For Docker, restore the old digest in `.env` and run `docker compose up -d`. Check schema compatibility for the selected older build before serving data. An executable rollback does not restore the databases. The additive recovery table and actor index remain readable by older servers, but authentication protection can differ. The reference server and older Candidate builds do not enforce credential epochs or the member host’s live session check. They can accept revoked, unexpired legacy tokens after a password recovery. If recovery must remain effective, rotate the token-signing secrets and keys and require sign-in again before serving with such a build. Keep the account database and its recovery table in every [backup](https://pds.linkjar.io/operate/backup/). # How it fits together > The parts of the server, what it writes to disk, and the two ways to deploy it, in three diagrams. [Source](https://pds.linkjar.io/reference/architecture/) The server is one process with three listeners: the public one that Caddy forwards to, and two private ones for metrics and for the console. It keeps everything in one data directory. ## Who talks to it ![System context: apps and clients reach the PDS over XRPC and OAuth; the PDS reaches the relay, the PLC directory, the AppView and SMTP; the console and the MCP server sit beside it](https://pds.linkjar.io/_astro/02-system-context.BpAxIMnP.svg) Apps sign in and read and write over XRPC. The relay subscribes to the firehose. The server registers DIDs with the PLC directory and forwards app requests to the AppView. Apps, the Bluesky app among them, sign in with OAuth or a password and read and write records over XRPC. The relay at `bsky.network` subscribes to the firehose and feeds the AppView, which serves timelines and notifications back to the apps through the server. The PLC directory holds the DID documents. The two sidecars are optional. ## What it writes ![Storage: the data directory with account.sqlite, sequencer.sqlite, did_cache.sqlite, audit.sqlite and ops.sqlite, one SQLite store and key per account, and the blobs on disk or in S3](https://pds.linkjar.io/_astro/07-storage.DeF39TF-.svg) The data directory has the reference server's layout: shared databases, one store and one signing key per account, and the blobs. Each account’s repository is a SQLite file of its own, with its signing key beside it. The shared databases hold the accounts and sessions, the event log of the firehose, cached DID documents, the audit log, and the server’s operator state. Blobs are files, or objects in a bucket. [Back up and restore](https://pds.linkjar.io/operate/backup/) says which to keep. ## One host, or an entryway ![Topologies: a single node with one data directory replicated to object storage, and an entryway that keeps the accounts in front of member hosts that keep the repositories](https://pds.linkjar.io/_astro/15-topologies.EsCiNdZd.svg) A single node is the usual deployment. An entryway splits accounts from repositories to grow past one host. A single node serves everything from one data directory, and this guide is written for it. An [entryway](https://pds.linkjar.io/scale/entryway/) keeps the accounts and the OAuth server in front of a member host that keeps the repositories; today one member host is supported. ## Further reading * [docs/architecture](https://github.com/linkjar/pds/blob/main/docs/architecture/README.md): one diagram per part of the server, including the write path, the firehose, OAuth and the extension model. * [docs/SPEC.md](https://github.com/linkjar/pds/blob/main/docs/SPEC.md): the specification, which says what the server must do and where it differs from the reference server on purpose. # Troubleshooting > What goes wrong most, what it looks like, and what fixes it. [Source](https://pds.linkjar.io/reference/troubleshooting/) | You see | Cause | Fix | | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `check-config` names a variable | The value is missing or malformed. | Fix the setting in the runtime environment file and run the check again. The message says what shape it expects. | | `docker-compose: command not found`, or an error about the Compose file’s version | Compose version 1. | Install the Compose plugin and use `docker compose`, with a space. | | The server exits at start and the log says another server holds the lock | Another process still runs, or the lock file is left from a copy. | Check `systemctl status linkjar-pds` or `docker compose ps`; stop the process. A stale `linkjar-pds.lock` in a copied directory can be removed when no server runs there. | | `curl` to the server fails with a certificate error on the first request | Caddy fetches the certificate on the first connection, which takes a few seconds. | Try again. If it keeps failing, DNS does not point at the host, or port 80 or 443 is closed. | | A handle’s name gets no certificate | The wildcard record is missing, or the handle is not an active account. | Check `dig +short anything.pds.example.com`, and the `/tls-check` route in [the checks](https://pds.linkjar.io/start/verify/#the-certificate-guard). | | The Bluesky app signs in but cannot load settings, and the log shows `getPreferences` failing | `PDS_BSKY_APP_VIEW_URL` and `PDS_BSKY_APP_VIEW_DID` are unset. | Set both, as in the example file, and restart. | | Sign-up fails with an invite code error | `PDS_INVITE_REQUIRED` is on and the code is wrong or used up. | Create a code with the [admin API](https://pds.linkjar.io/operate/accounts/#invite-codes). | | Sign-up fails and the log mentions the rotation key | `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` is unset. | Generate one as in [the install](https://pds.linkjar.io/start/install/) and restart. Without it the server creates no account. | | Posts do not appear for people on other servers | The relay has not crawled the host yet, or cannot reach it. | Wait for the first write after a start, then check `getHostStatus` as in [the first account](https://pds.linkjar.io/start/first-account/#when-posts-reach-other-people). The firehose must be reachable at `wss://pds.example.com`. | | Password reset mail never arrives | SMTP is not set, or the URL is wrong. | [Email](https://pds.linkjar.io/configure/email/). A wrong URL shows in the log of the request. | | The firehose subscriber count stays at 0 | The relay is not connected. | Same as the posts above. A proxy in front of DNS that drops long WebSockets is a common cause. | | `verify` prints differences after a restore | The backup may be inconsistent, or blobs may be missing. | Restore a tested cold backup or consistent snapshot, including its WAL and external storage. Copying live files separately is insufficient. | | A second host started on a copy of the directory | Two servers served one set of accounts. | Stop one at once. The relay and the apps saw two histories; the one that keeps running is the truth, and the other’s writes since the copy are lost. | For native services, read `sudo journalctl -u linkjar-pds`; for Compose, read `docker compose logs pds`. Set `LOG_LEVEL=debug` and restart for more detail. A foreground native binary needs its settings exported; a nearby `.env` file is not loaded automatically. Check CA certificates if outbound HTTPS fails. Open an issue at [github.com/linkjar/pds](https://github.com/linkjar/pds/issues) with the relevant log lines, installation method, and source commit. Review logs and configuration excerpts for private information before sharing them. # Entryway and member host > Split one server into an entryway that keeps the accounts and a member host that keeps the repositories, without changing a DID document. [Source](https://pds.linkjar.io/scale/entryway/) An entryway is the way to grow past one host. It keeps the accounts, the sessions, the OAuth server and the PLC rotation key, and routes everything else to a member host, which keeps the repositories, the blobs, the signing keys and the firehose. The old server becomes the member host and keeps its address, so no DID document changes. Today an entryway serves one member host. Rehearse the split on a copy first, and tell the people on the server before the day: every OAuth client must sign in again, because the member host is no longer an authorization server. ## What to know first * `PDS_ENTRYWAY_URL` of the member host is the public address of the entryway. OAuth clients read it, and tokens name it as their issuer. * Sessions with a password or an app password carry on: the client refreshes once and gets tokens of the entryway. * After local token checks, the member checks current legacy or OAuth session state at the entryway. Results are not cached. Password recovery takes effect at the next authenticated member request. This adds one round trip, capped at five seconds or `PDS_PROXY_HEADERS_TIMEOUT` if shorter. If the entryway cannot answer, the member refuses the request with 503 `UpstreamFailure`. * `PDS_ENTRYWAY_ADMIN_TOKEN` must contain the entryway’s admin password. The member uses it for the private `/oauth/introspect` check and admin forwarding. Keep it in the member’s secret store. * The entryway passes uploads, exports and the firehose through to the member host as streams. Only the member host asks the relay to crawl it. * A member host answers no handle. `/.well-known/atproto-did` on the handle names must reach the entryway, so the wildcard DNS and the Caddyfile move to it. ## Prepare 1. Choose the entryway’s name, such as `entryway.example.com`, and point it at the new host. 2. Create the key of the tokens, 32 random bytes as 64 hexadecimal digits: ```bash openssl rand -hex 32 ``` It goes into the entryway’s secrets. The member host needs the public key, which the entryway logs at start as `jwt_verify_key_k256_public_key_hex`, with its DID. 3. Note the `did:key` of the old server’s PLC rotation key. The entryway takes the private key; the member host gets the `did:key`. ## Split 1. Stop the old server. 2. Copy the complete `account.sqlite`, including `credential_epoch`, from its data directory to the entryway’s. 3. Configure the entryway with the old server’s variables, and: | Variable | Value | | --------------------------------------------------- | --------------------------------------------------------- | | `PDS_HOSTNAME` | the entryway’s name | | `PDS_JWT_SECRET` | the old server’s; it takes the refresh tokens from before | | `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | the old server’s | | `PDS_MEMBER_URL` | the old server’s public address | | `PDS_MEMBER_INTERNAL_URL` | where the entryway reaches it | | `PDS_MEMBER_ADMIN_PASSWORD` | the old server’s admin password | | `PDS_ENTRYWAY_JWT_SIGNING_KEY_K256_PRIVATE_KEY_HEX` | the new key | 4. Configure the old server as the member host. Keep its variables, and: | Variable | Value | | ------------------------------------------------- | ------------------------------------------------------------------------------------------------ | | `PDS_ENTRYWAY_URL` | the entryway’s address | | `PDS_ENTRYWAY_DID` | `did:web:` and the entryway’s name | | `PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX` | the public key | | `PDS_ENTRYWAY_PLC_ROTATION_KEY` | the `did:key` of the rotation key | | `PDS_ENTRYWAY_ADMIN_TOKEN` | the entryway’s `PDS_ADMIN_PASSWORD` | | `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | remove it | | `PDS_JWT_SECRET` | keep it; the member host answers `ExpiredToken` to a token from before, and the client refreshes | 5. Send `/.well-known/atproto-did` of the handle names to the entryway. 6. Start the entryway, then the member host. ## Check 1. Sign in at the member host’s address with a password. The entryway answers, and the session writes a record. 2. Refresh a session from before the split. 3. Create an account at the entryway. Its DID document names the member host. 4. Change a handle. Both servers show it. 5. Recover a test account’s password. Its previous legacy and OAuth tokens must fail on the member host; a fresh sign-in must work. ## Reconcile A crash during a sign-up can leave a repository on the member host with no account at the entryway. At the entryway, use `pds reconcile` with the [native CLI helper](https://pds.linkjar.io/operate/cli/#native-services), or for Compose: ```bash docker compose exec pds linkjar-pds reconcile ``` It lists each repository without an account and each account without a repository, and exits 1 when it finds one. Run it again with `--remove-orphans` to remove the repositories without an account; one with a commit in the last ten minutes stays, because it may be a sign-up in progress. ## Back to one server Stop both. Remove the `PDS_ENTRYWAY_*` variables from the old server and give it its rotation key back. Copy `account.sqlite` from the entryway back: it has the accounts, sessions and recovery epochs since the split. A repository the member host created since then is in its directory already. Start the old server; clients refresh once more. The [runbook](https://github.com/linkjar/pds/blob/main/docs/runbooks/entryway.md) in the repository has the same procedure with the specification’s references. # Postgres for the shared tier > Move the accounts, the event log, the DID cache and the audit log from SQLite files to Postgres, and back. [Source](https://pds.linkjar.io/scale/postgres/) Four of the server’s databases are shared by every account: the accounts, the event log, the DID cache and the audit log. They can live in Postgres instead of SQLite files. The repositories and the blobs stay in the data directory either way. Most hosts never need this. Postgres is for an operator whose backups and replication are already Postgres, or who plans an [entryway](https://pds.linkjar.io/scale/entryway/) later. ## What to know first * **One server.** The tier serves one `linkjar-pds` process. A second one on the same schemas exits 2 at start. * **No TLS.** The server reaches Postgres without TLS. Run the two on one host or one private network. The URL takes no option but `sslmode=disable`. * **Sign-in** with `scram-sha-256` or a clear-text password. `md5` is not supported. * **Backups change.** A restore must bring back Postgres and the data directory from the same moment, because the repositories and the event log refer to each other. Preserve the account schema’s `credential_epoch` table so password recovery continues to reject old tokens. Storage migration copies this table in both directions. ## Command conventions The examples below use Compose. For NixOS or a native systemd service, use `sudo systemctl stop linkjar-pds` and `sudo systemctl start linkjar-pds`. Replace `docker compose run --rm pds linkjar-pds ` with `pds ` through the [native CLI helper](https://pds.linkjar.io/operate/cli/#native-services). Update the native runtime file and use the database’s reachable host address; the Compose name `db` does not resolve on a plain host. Keep the server stopped during migration. ## Move to Postgres 1. Create a database and a role that owns it. The server creates four schemas in it: `pds_account`, `pds_sequencer`, `pds_did_cache` and `pds_audit`. 2. Stop the server. ```bash docker compose stop pds ``` 3. Add the URL to `pds.env`. Set `PDS_POSTGRES_SCHEMA_PREFIX` when `pds` is taken. Remove `PDS_ACCOUNT_DB_LOCATION`, `PDS_SEQUENCER_DB_LOCATION` and `PDS_DID_CACHE_DB_LOCATION` if they are set, so that the copy finds the files at their default places. ```ini PDS_POSTGRES_URL=postgres://pds:password@db:5432/pds ``` 4. Copy. ```bash docker compose run --rm pds linkjar-pds migrate-storage --to postgres ``` It prints one line per table and ends with a line that says the row counts, the head of the event log and the last checkpoint are the same on both sides. An exit code of 2 means nothing was switched: read the message. 5. Check the directory against the new tier, then start. ```bash docker compose run --rm pds linkjar-pds verify ``` ```bash docker compose up -d ``` 6. Keep the SQLite files until the first backup of Postgres exists. Then move them out of the data directory: a later copy back needs the places empty. ## Back to SQLite 1. Stop the server. 2. Move `account.sqlite`, `sequencer.sqlite`, `did_cache.sqlite` and `audit.sqlite` out of the data directory, with their `-wal` and `-shm` files. The copy refuses a target that exists. 3. Copy, with `PDS_POSTGRES_URL` still set: ```bash docker compose run --rm pds linkjar-pds migrate-storage --to sqlite ``` 4. Remove `PDS_POSTGRES_URL` from `pds.env`, run `verify`, and start. ## When the copy fails The copy writes to the target only, so a copy that fails leaves the source as it was. Remove what the target got, the four schemas in Postgres or the four files on disk, and run the copy again. # Console and MCP server > Optional console and MCP sidecars, with Compose deployment examples and native build scope. [Source](https://pds.linkjar.io/scale/sidecars/) For a first setup, use the dedicated [MCP guide](https://pds.linkjar.io/connect/mcp/) or [operations console guide](https://pds.linkjar.io/connect/console/). This page keeps the Compose examples and existing links together. The [binary and port map](https://pds.linkjar.io/reference/binaries/) explains the native equivalents. Both sidecars talk to the server over its APIs. Neither holds a database connection, a signing key or a secret of the server, so each can be added and removed without touching the data directory, and every action they take is in the [audit log](https://pds.linkjar.io/operate/audit-log/). The examples on this page use Docker Compose. The native PDS archives and Nix packages include only `linkjar-pds`, not these sidecars. A native PDS can use separately built sidecars through the same APIs. Replace Compose DNS names with reachable host addresses and keep operations listeners private. Native listeners on the same host should use loopback, not the container-only `0.0.0.0` examples below. ## The operations console A page with the live numbers of the server and the firehose subscribers, the accounts and the sessions of each, the audit log, the blocked email domains and the operator roles. It takes an account down and lifts the takedown, ends an account’s sessions, disconnects a subscriber, blocks an email domain, signs a checkpoint, and removes expired sessions. Each form has a field for the reason, which goes into the audit entry. An operator signs in with their own account on the server, through OAuth, and the account needs a role. The console is a loopback client: reach it through an SSH tunnel, never under a public name. ### Run it On the server’s side, in `pds.env`: ```dotenv PDS_OPS_ADDRESS=0.0.0.0:2584 ``` In `compose.yml`, a service beside `pds`: ```yaml console: image: ghcr.io/linkjar/pds-console@sha256:… restart: unless-stopped environment: CONSOLE_ADDRESS: 0.0.0.0:2585 CONSOLE_PUBLIC_URL: http://127.0.0.1:2585 CONSOLE_PDS_PUBLIC_URL: https://pds.example.com CONSOLE_PDS_INTERNAL_URL: http://pds:3000 CONSOLE_OPS_URL: http://pds:2584 ports: - "127.0.0.1:2585:2585" ``` Start it and read its client id from its first log lines: ```bash docker compose up -d console && docker compose logs console ``` Put the id into `pds.env` as `PDS_OPS_CLIENT_IDS` and restart the server. The ops listener takes a token only from a client on that list. ### Grant a role Roles are `operator`, which takes every action but a role grant, and `moderator`, which reads, changes the status of a subject, ends sessions and disables invites. Only the admin password grants a role. Publish the ops listener on the host’s loopback, beside the console’s port: ```yaml ports: - "127.0.0.1:2584:2584" ``` Then, with `PDS_ADMIN_PASSWORD` in the environment and a reason, which every action on the ops listener requires: ```bash curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'X-Ops-Reason: first operator' -H 'content-type: application/json' -d '{"did": "did:plc:…", "role": "operator"}' http://127.0.0.1:2584/xrpc/internal.ops.grantRole ``` ### Open it From your workstation, a tunnel to the host: ```bash ssh -L 2585:127.0.0.1:2585 operator@pds.example.com ``` Open `http://127.0.0.1:2585`, and sign in with the account that holds the role. A restart of the console signs every operator out: it keeps the sessions in memory. ## The MCP server An MCP server that AI clients connect to with OAuth, in order to read and write an account’s records with the account’s consent. It is a public service under a name of its own, such as `mcp.example.com`, behind Caddy. Toward the PDS it is an OAuth client with a key of its own; its own tokens never reach the PDS, and each write names the AI client in the audit entry. Its configuration is `MCP_ADDRESS`, `MCP_PUBLIC_URL`, `MCP_PDS_PUBLIC_URL`, `MCP_PDS_INTERNAL_URL`, `MCP_CLIENT_KEY_P256_PRIVATE_KEY_HEX` and `MCP_WRITE_COLLECTIONS`, the collections an AI client may ask to write. Its client id is `MCP_PUBLIC_URL` followed by `/oauth-client-metadata.json`, and it logs it at start. On the server’s side, `PDS_MCP_CLIENT_IDS` names it, and `PDS_OAUTH_KNOWN_CLIENTS_FILE` can hold its client metadata so that the server fetches nothing. Sessions live in the process’s memory, so one instance runs and a restart ends every session. The design and the state of both sidecars are in [docs/sidecars.md](https://github.com/linkjar/pds/blob/main/docs/sidecars.md) in the repository.