Systemd Service
Systemd Service
Migration in progress.
api.legendary-arena.comand its PostgreSQL are moving off Render onto a self-hosted DigitalOcean Ubuntu droplet fronted by Cloudflare, perdocs/PLAN.md. Until decommission, Render stays warm as the rollback target.
Summary
The la-server systemd unit is the supervisor that keeps the Legendary Arena application running on the droplet. It orders startup after PostgreSQL, loads the environment file, runs the app through an fnm-pinned Node, and restarts it on failure and after reboot.
Mechanics
The owning artifact is infra/systemd/la-server.service
. Broken down by unit section:
[Unit]—After=network.target postgresql.serviceorders the service to start once the network and PostgreSQL are up;Wants=postgresql.servicemakes the database a soft dependency (desired, not strictly required).[Service]— runs asUser=operator/Group=operatorwithWorkingDirectory=/opt/legendary-arena. It loadsEnvironmentFile=/etc/la/.env.ExecStartinvokes the app through the fnm-pinned runtime:/opt/fnm/fnm exec 24.18.0 pnpm --filter @legendary-arena/server start.Restart=on-failurewithRestartSec=5gives a 5-second backoff, andTimeoutStopSec=30allows 30 seconds for graceful shutdown before a kill.[Install]—WantedBy=multi-user.targetenables the service at normal multi-user boot.
[Service]
Type=simple
User=operator
Group=operator
WorkingDirectory=/opt/legendary-arena
EnvironmentFile=/etc/la/.env
ExecStart=/opt/fnm/fnm exec 24.18.0 pnpm --filter @legendary-arena/server start
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
Systemd is chosen over PM2 because it is native to the box, survives reboot, and routes logs to journald; the migration replaces the original PM2 process model with this unit, per docs/PLAN.md
.
Interactions
- Deploy Server — installs and enables this unit as part of provisioning the droplet.
- Secrets and Env
— owns
/etc/la/.env, theEnvironmentFilethis unit loads at start. - Fail2ban and Unattended Upgrades
— reboots triggered by unattended upgrades rely on
WantedBy=multi-user.targetto bring the service back automatically. infra/systemd/la-server.service— the owning unit file itself.
Edge Cases
EnvironmentFile=/etc/la/.envmust exist and be readable (mode 600); if it is missing the service fails to start — see Secrets and Env .ExecStarthard-codes the fnm path/opt/fnm/fnmand Node24.18.0, so the node-runtime step must have installed exactly that path and version or the unit cannot launch.After=postgresql.serviceassumes a co-located database on the same box; a remote-DB topology would not satisfy this ordering as written.- On reboot — for example after an unattended upgrade — systemd brings the service back via
WantedBy=multi-user.target, which is why reboot survival ties to Fail2ban and Unattended Upgrades .
References
infra/systemd/la-server.service— owning artifact, the unit definition.docs/PLAN.md— migration plan; replaces the PM2 model with systemd.content/app/deploy-server.md— operator content page for server deployment.- Secrets and Env
— the
EnvironmentFileconsumed by this unit. - Deploy Server — installs and enables the unit.