Commands
This page is for the operator who runs commands against an Adiutor server. It covers how to run one on each kind of host, what each command does, and the commands that must never run on a server.
The commands are pnpm scripts in the app. They read the same settings the server does, so they work on the same database. They need the development dependencies, so never prune them (pnpm prune --prod).
Running a command
Section titled “Running a command”With Docker Compose, a one-off container of the app service:
docker compose run --rm app pnpm <command>With docker run, giving the settings the server uses:
docker run --rm --env-file .env bastolen/adiutor:0.5.0 pnpm <command>The image sets NODE_ENV=production itself. A command that touches files on disk needs the same volume as the app.
From the app’s folder, as the user the app runs as, with NODE_ENV=production. The commands read .env in the folder they run in, which only that user and root can read on A plain Node.js server:
sudo -u adiutor -H env NODE_ENV=production pnpm <command>Vercel has no shell for the app. Run commands from a checkout of the release’s tag on your own computer:
- Check out the tag and run
pnpm install. - Put the environment’s settings in a
.envfile in that folder, for example withvercel env pull .env --environment=productiononce the folder is linked to the project (vercel link). Variables marked Sensitive in Vercel come without their values: add those yourself. - Run the command with
NODE_ENV=production. - Delete the
.envfile afterwards: it holds your secrets.
For pnpm db:migrate, DATABASE_URL must point at the unpooled (direct) connection: give it the value of DATABASE_URL_UNPOOLED, since the command reads only DATABASE_URL.
The commands
Section titled “The commands”| Command | What it does |
|---|---|
pnpm db:migrate |
Brings the database to the schema of this release |
pnpm setup:platform --staff-name … --email … --name … |
Names the staff and creates the first Admin |
pnpm jobs:run |
Runs one tick of the background jobs |
pnpm jobs:run <name> |
Runs one scheduled job now |
pnpm jobs:list |
Lists every job with its state, last and next run |
pnpm jobs:retry <id> or --kind <kind> |
Puts failed queued jobs back in the queue |
pnpm jobs:discard <id> or --kind <kind> |
Discards failed queued jobs |
pnpm sessions:revoke-all --yes or --user <email> |
Signs everyone, or one user, out everywhere |
Migrate
Section titled “Migrate”pnpm db:migrate applies the migrations the release brings. Run it with every release, before the new version serves traffic. Migrations only go forward. See Upgrading.
Set up
Section titled “Set up”pnpm setup:platform names the staff and creates the first staff Admin, with --staff-name, --email and --name, and optionally --default-language (such as nl-NL) and --time-zone (such as Europe/Amsterdam). It refuses once Adiutor is set up. See First run.
pnpm jobs:runruns one tick and prints a line for each job that ran, or “Nothing was due.” It exits with 1 when a job failed, after the others ran, and 2 for a mistake in the command.pnpm jobs:run <name>runs that scheduled job now, whether it’s due or paused. If it’s already running, it says so and exits with 1. An unknown name lists the jobs.pnpm jobs:listprints each scheduled job with its schedule (UTC), whether it’s waiting, paused or running, and its last and next run. Then each kind of queued job with how many wait and failed, and the IDs of failed jobs.pnpm jobs:retryandpnpm jobs:discardtake a failed job’s ID, or--kind <kind>for every failed job of a kind, and say how many they changed.
How to schedule the tick is on Background jobs.
Sign people out
Section titled “Sign people out”pnpm sessions:revoke-all --user [email protected]ends all of that user’s sessions and forgets the devices they trusted, so a stolen one asks for the second step again. They get a security email at the next tick of the background jobs.pnpm sessions:revoke-all --yesdoes it for everyone. Nobody is emailed: tell people yourself. Without--yesor--user, the command refuses.
Both print how many sessions they ended and are recorded in the audit log. See After a suspected leak.
Never on a server
Section titled “Never on a server”pnpm db:seeddeletes all data and adds accounts whose passwords and authenticator secrets are public. It refuses to run whenBETTER_AUTH_URLisn’t on this computer, or whenNODE_ENVisproduction, but don’t rely on that.pnpm db:seed:attachmentsadds test files to a development database.pnpm db:generatecreates new migrations from the code. It’s for developers.pnpm auth:schemaregenerates the sign-in library’s database schema. It’s for developers.- Never set
EMAIL_OUTBOX_DIRorE2E_TESTS. They exist for the tests.
Example
Section titled “Example”Adiutor at https://adiutor.dev runs on Docker Compose. After a laptop with a trusted device goes missing, Alex Admin runs docker compose run --rm app pnpm sessions:revoke-all --user [email protected]. The command prints how many sessions it ended, and Alex gets a security email at the next tick.
Good to know
Section titled “Good to know”- A command exits with 0 when it succeeded, so scripts and cron can rely on the exit code.
- The commands keep database values out of their output, like the server does. See Logs and error references.
Related
Section titled “Related”Adiutor's code is released under the MIT License. The Adiutor name and logo aren’t covered by it; see the notice.
Set in Inter and JetBrains Mono, under the SIL Open Font License (Inter, JetBrains Mono).