Skip to content

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.

  • 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 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.

  1. 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 adiutor
    install -d -o root -g root -m 755 /var/lib/adiutor
  2. Get the release:

    Terminal window
    git clone https://github.com/bastolen/adiutor.git /srv/adiutor
    cd /srv/adiutor
    git checkout v0.5.0
  3. Install the dependencies, exactly as the lockfile has them: HUSKY=0 pnpm install --frozen-lockfile. HUSKY=0 skips the Git hooks, which a server doesn’t need.

  4. Write the settings in .env, based on .env.example. At least DATABASE_URL, BETTER_AUTH_URL=https://adiutor.dev, a BETTER_AUTH_SECRET of at least 32 characters (openssl rand -base64 32), CLIENT_IP_HEADERS=x-real-ip behind the proxy, and a mail server (SMTP_URL and EMAIL_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.

  5. Build with those settings in place, from a fresh .next, then give the app the one folder it writes to:

    Terminal window
    rm -rf .next
    pnpm build
    rm -rf .next/cache/turbopack
    chown -R adiutor:adiutor .next

    Every build starts like this. Once the app’s user owns .next, a build as root must never read or follow anything it left there, and rm -rf follows no links.

  6. Create the tables, as the app’s user: sudo -u adiutor -H env NODE_ENV=production pnpm db:migrate.

  7. 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, and pnpm start reads .env by itself.

  8. Put the reverse proxy with HTTPS in front: see Reverse proxy.

  9. Open https://adiutor.dev and follow First run right away. Until then, whoever opens /setup first 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.

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.

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 .next as in step 5. Upgrading has the steps.
  • Commands that only use it (pnpm db:migrate, pnpm jobs:run and the others in Commands) run as the app’s user, which can read .env: for example sudo -u adiutor -H env NODE_ENV=production pnpm db:migrate.
/etc/systemd/system/adiutor.service
[Unit]
Description=Adiutor
After=network-online.target postgresql.service
Wants=network-online.target
[Service]
User=adiutor
WorkingDirectory=/srv/adiutor
Environment=NODE_ENV=production
PrivateTmp=yes
ExecStart=/usr/local/bin/pnpm start --hostname 127.0.0.1 --port 3000
Restart=on-failure
[Install]
WantedBy=multi-user.target

Enable and start it:

Terminal window
sudo systemctl enable --now adiutor
sudo systemctl status adiutor

The logs go to the journal: journalctl -u adiutor. See Logs and errors.

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:

/etc/systemd/system/adiutor-jobs.service
[Unit]
Description=Adiutor background jobs
[Service]
Type=oneshot
User=adiutor
WorkingDirectory=/srv/adiutor
Environment=NODE_ENV=production
PrivateTmp=yes
ExecStart=/usr/local/bin/pnpm jobs:run
/etc/systemd/system/adiutor-jobs.timer
[Unit]
Description=Run Adiutor's background jobs every 5 minutes
[Timer]
OnCalendar=*:0/5
[Install]
WantedBy=timers.target
Terminal window
sudo systemctl daemon-reload
sudo systemctl enable --now adiutor-jobs.timer

Or 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>&1

A 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.

On a server for https://adiutor.dev, with the app in /srv/adiutor:

Terminal window
sudo systemctl status adiutor adiutor-jobs.timer
curl -s http://127.0.0.1:3000/api/health

The second command prints {"status":"ok"} when the database answers and every migration is applied.

  • Migrate before you restart on a new release; the new build must never run against the old schema.
  • Never run pnpm db:seed on a server: it deletes all data.
  • Keep the app’s port private: only the reverse proxy reaches 127.0.0.1:3000.

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).