A plain Node.js server
This page is for operators who run Adiutor on a server of their own without containers. It covers what you need, installing a release, why the development dependencies stay, running the app as a service and starting the background jobs.
What you need
Section titled “What you need”- Node.js 26.13 or newer, the current LTS.
- pnpm 12.22.0, the version Adiutor names. Node.js no longer ships Corepack, so install exactly that version for every user:
npm install –global [email protected]. Every user then runs the same pnpm, which root owns, instead of downloading one of their own. - PostgreSQL 18, which you run and back up.
- git, to get a release.
- A reverse proxy in front, with HTTPS: see Reverse proxy.
Install
Section titled “Install”Install from a release’s tag, in the folder the app runs from (here /srv/adiutor). Run these steps as root, for example after sudo -i, and start with umask 022, so the app’s user can read what root makes even where the server’s umask is stricter. Root owns the code, and the app runs as a user of its own that can’t change it, as in the Docker image.
-
Make the user the app runs as, with a home outside the app’s folder that it can read but not write:
Terminal window useradd --system --home-dir /var/lib/adiutor --shell /usr/sbin/nologin adiutorinstall -d -o root -g root -m 755 /var/lib/adiutor -
Get the release:
Terminal window git clone https://github.com/bastolen/adiutor.git /srv/adiutorcd /srv/adiutorgit checkout v0.5.0 -
Install the dependencies, exactly as the lockfile has them:
HUSKY=0 pnpm install --frozen-lockfile.HUSKY=0skips the Git hooks, which a server doesn’t need. -
Write the settings in
.env, based on.env.example. At leastDATABASE_URL,BETTER_AUTH_URL=https://adiutor.dev, aBETTER_AUTH_SECRETof at least 32 characters (openssl rand -base64 32),CLIENT_IP_HEADERS=x-real-ipbehind the proxy, and a mail server (SMTP_URLandEMAIL_FROM, or later in Settings). See Environment variables. Then let the app’s user read it, and nobody else:chown root:adiutor .env && chmod 640 .env. -
Build with those settings in place, from a fresh
.next, then give the app the one folder it writes to:Terminal window rm -rf .nextpnpm buildrm -rf .next/cache/turbopackchown -R adiutor:adiutor .nextEvery build starts like this. Once the app’s user owns
.next, a build as root must never read or follow anything it left there, andrm -rffollows no links. -
Create the tables, as the app’s user:
sudo -u adiutor -H env NODE_ENV=production pnpm db:migrate. -
Run it as a service, below. It starts with
pnpm start --hostname 127.0.0.1 --port 3000, listening only on the loopback address for the reverse proxy, andpnpm startreads.envby itself. -
Put the reverse proxy with HTTPS in front: see Reverse proxy.
-
Open
https://adiutor.devand follow First run right away. Until then, whoever opens/setupfirst becomes the staff Admin.
Then start the background jobs. If attached files go to a folder on this server, create it for the app’s user, as in File storage. To move to a newer release, see Upgrading.
Keep the development dependencies
Section titled “Keep the development dependencies”The commands you run on the server need them: pnpm db:migrate runs drizzle-kit, and the background jobs, the first-run setup and signing everyone out after a leak run through tsx. Without them, migrations, jobs, setup and that sign-out all fail, possibly in the middle of an incident.
The commands read .env from the folder they run in, and should run with NODE_ENV=production on a server (the Docker image sets it for you). See Commands.
Run it as a service
Section titled “Run it as a service”A systemd unit keeps the app running and starts it at boot, as the adiutor user from the first step. command -v pnpm prints the path to put in ExecStart (below it is /usr/local/bin/pnpm).
The code and the app’s home belong to root, so a flaw that lets the app write files can’t change its code, its dependencies, or the pnpm that starts it and the settings pnpm reads from that home. The app writes only to .next (Next.js’s image and data caches), which every build replaces, and, with attached files on this server, to their folder. From now on:
- Commands that change the code (
git,pnpm install, a build) run as root, with the app stopped, and a build always starts from a fresh.nextas in step 5. Upgrading has the steps. - Commands that only use it (
pnpm db:migrate,pnpm jobs:runand the others in Commands) run as the app’s user, which can read.env: for examplesudo -u adiutor -H env NODE_ENV=production pnpm db:migrate.
[Unit]Description=AdiutorAfter=network-online.target postgresql.serviceWants=network-online.target
[Service]User=adiutorWorkingDirectory=/srv/adiutorEnvironment=NODE_ENV=productionPrivateTmp=yesExecStart=/usr/local/bin/pnpm start --hostname 127.0.0.1 --port 3000Restart=on-failure
[Install]WantedBy=multi-user.targetEnable and start it:
sudo systemctl enable --now adiutorsudo systemctl status adiutorThe logs go to the journal: journalctl -u adiutor. See Logs and errors.
Start the background jobs
Section titled “Start the background jobs”Adiutor’s background work is started by a tick every 5 minutes. On a plain server, run pnpm jobs:run on a schedule, with the same user, folder and NODE_ENV. A systemd timer:
[Unit]Description=Adiutor background jobs
[Service]Type=oneshotUser=adiutorWorkingDirectory=/srv/adiutorEnvironment=NODE_ENV=productionPrivateTmp=yesExecStart=/usr/local/bin/pnpm jobs:run[Unit]Description=Run Adiutor's background jobs every 5 minutes
[Timer]OnCalendar=*:0/5
[Install]WantedBy=timers.targetsudo systemctl daemon-reloadsudo systemctl enable --now adiutor-jobs.timerOr cron, in the adiutor user’s crontab (sudo crontab -u adiutor -e). Cron’s own PATH leaves out /usr/local/bin, so the first line sets it. Create the log file for that user first, or the line can’t write to it and the tick never starts: sudo install -o adiutor -g adiutor -m 640 /dev/null /var/log/adiutor-jobs.log.
PATH=/usr/local/bin:/usr/bin:/bin*/5 * * * * cd /srv/adiutor && NODE_ENV=production pnpm jobs:run >> /var/log/adiutor-jobs.log 2>&1A run that overlaps the next one does no harm. It exits with 1 when a job failed, so your monitoring can notice. The rest, including checking on the jobs, is in Background jobs.
Example
Section titled “Example”On a server for https://adiutor.dev, with the app in /srv/adiutor:
sudo systemctl status adiutor adiutor-jobs.timercurl -s http://127.0.0.1:3000/api/healthThe second command prints {"status":"ok"} when the database answers and every migration is applied.
Good to know
Section titled “Good to know”- Migrate before you restart on a new release; the new build must never run against the old schema.
- Never run
pnpm db:seedon a server: it deletes all data. - Keep the app’s port private: only the reverse proxy reaches
127.0.0.1:3000.
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).