Sign In
Deploy

Deploying to VMs & Bare Metal

Run your backend on any Linux VM or bare metal host with a basic systemd unit.

Guide

Upload Your App

  • Build your backend locally.
  • Copy the build output to your server (example):
scp -r ./dist user@server:/opt/backend
Command Line

Place the files somewhere readable by the service user, such as /opt/backend.

Generate Environment Variables

Navigate to Rivet and click Connect > Manual. Copy the environment variables provided, they will be used in the next step. They should look something like this:

RIVET_API_ENDPOINT=https://api-us-west-1.rivet.dev
RIVET_NAMESPACE=your-namespace-id
RIVET_TOKEN=your-token
Command Line

Create the systemd Service

Create /etc/systemd/system/backend.service:

[Unit]
Description=Backend Service
After=network.target

[Service]
Type=simple
WorkingDirectory=/opt/backend
ExecStart=/usr/bin/node server.js
Restart=on-failure
Environment=RIVET_API_ENDPOINT=https://api.rivet.dev
Environment=RIVET_NAMESPACE=your-namespace-id
Environment=RIVET_TOKEN=your-token

[Install]
WantedBy=multi-user.target
Configuration

Replace the environment values with those from the Connect tab in the Rivet dashboard (or your self-hosted engine) and adjust paths to match your deployment.

Start and Manage the Service

Reload systemd units and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now backend.service
Command Line

Operating

Restart

Restart the service after deploying new builds or environment changes:

sudo systemctl restart backend.service
Command Line

Logs

Follow realtime logs when debugging:

sudo journalctl -u backend.service -f
Command Line
Suggest changes to this page