Pages

Deployment

How to run a Carrier board on a server: install it, keep it running, expose it, back it up and upgrade it. For local development, see getting started.

All callers share one PHP process (see architecture). Restarting the process disconnects every caller.

Requirements

  • PHP 8.5 CLI with gmp, intl, mbstring, openssl, pdo_sqlite and sodium (from framework/composer.json)
  • Composer
  • pcntl, for clean shutdown. serve waits on SIGINT/SIGTERM with Amp's trapSignal(), and Revolt's default event loop driver throws "Signal handling requires the pcntl extension" without it. The framework's composer.json only suggests it, so Composer doesn't enforce it.

1. Install

git clone <your repository> /srv/bbs
cd /srv/bbs
composer install --no-dev --optimize-autoloader
cp .env.example .env

The dev dependencies (Pest, phpseclib, the websocket client) are only used by the tests.

2. Configure the environment

.env is read by Tempest at boot. Variables already set in the process environment win over .env, because Tempest loads it with Dotenv::createUnsafeImmutable(). Settings for a production board:

ENVIRONMENT=production
DISCOVERY_CACHE=true
LOG_LEVEL=info

BBS_NAME="The Neon Basement"
BBS_SYSOP=Phosphor
BBS_HOSTNAME=bbs.example.org
BBS_NODES=16

TELNET_ADDRESS=0.0.0.0:2323
SSH_ADDRESS=0.0.0.0:2222
RLOGIN_ADDRESS=off
WEB_ADDRESS=127.0.0.1:8080

DB_DATABASE=storage/carrier.sqlite
Variable Read by Default Notes
TELNET_ADDRESS, SSH_ADDRESS, RLOGIN_ADDRESS, WEB_ADDRESS servers.config.php 0.0.0.0:2323, :2222, :2513, :8080 off disables the listener
BBS_NAME, BBS_SYSOP, BBS_LOCATION, BBS_TAGLINE, BBS_HOSTNAME, BBS_NODES, BBS_THEME bbs.config.php see file BBS_NODES caps concurrent callers
DB_DATABASE database.config.php storage/carrier.sqlite relative paths are resolved from the project root
LOG_LEVEL Logger info PSR-3 level names
ENVIRONMENT Tempest local production and staging turn on Tempest's discovery and config caches by default
DISCOVERY_CACHE Tempest partial when local, true in production or staging, otherwise off true/full, partial, or false

The full list of board settings is in configuration.

3. Create the database and the sysop

php carrier migrate --seed
php carrier user:create Phosphor --sysop

--seed adds the starter areas, a welcome thread, a poll and oneliners. Leave it off for an empty board. Without a sysop account, the first caller to apply becomes sysop.

4. Generate the SSH host keys

php carrier ssh:keygen

This creates storage/keys/ssh_host_ed25519 and storage/keys/ssh_host_rsa.pem (mode 0600, directory 0700) and prints their fingerprints. serve creates missing keys on first start too, but running it yourself gives you the fingerprints to publish on your website or in your BBS list entries.

Back up storage/keys/. Losing it changes the fingerprints, and every returning SSH caller gets a host-key warning. --force regenerates both keys on purpose.

5. Cache discovery

With DISCOVERY_CACHE=true, Tempest reads discovery from a cache instead of reflecting every class at boot. Build the cache after every deploy:

php carrier discovery:generate

When the strategy resolves to off, the command prints "Discovery cache disabled, nothing to generate." and does nothing. With the cache on, a new module, door, display code or menu class is not seen until you run discovery:generate again.

With ENVIRONMENT=production, Tempest also caches the list of *.config.php files in .carrier/cache/config (CONFIG_CACHE defaults to on there). Values are still read on every boot, but a newly added config file is only picked up after you delete that directory.

Tempest keeps both caches in .carrier/, relative to the current working directory. Always run php carrier from the project root; the unit file below sets WorkingDirectory for this reason.

6. Run it under systemd

An example unit, built from the real serve options. Adjust the user, paths and PHP binary.

# /etc/systemd/system/carrier.service  (example)
[Unit]
Description=Carrier BBS
After=network-online.target
Wants=network-online.target

[Service]
User=bbs
Group=bbs
WorkingDirectory=/srv/bbs
ExecStart=/usr/bin/php /srv/bbs/carrier serve --quiet
Restart=always
RestartSec=2
KillSignal=SIGTERM
TimeoutStopSec=15

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now carrier
journalctl -u carrier -f
  • --quiet keeps log lines out of the console (and the journal); they still go to storage/logs/carrier.log. Drop --quiet to read the log with journalctl instead.
  • On SIGTERM, Carrier stops the listeners, tells every caller "The system is going down. Call back soon!" and disconnects them.
  • Restart=always brings the board back after a crash. A class that fails to load stops the process at boot, so a broken deploy shows up as a restart loop in systemctl status.

Ports below 1024

Telnet's standard port is 23 and SSH's is 22. Linux only lets root, or a process with CAP_NET_BIND_SERVICE, bind below 1024. Either grant the capability in the unit:

[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE

or keep Carrier on high ports and forward with the firewall. If the system's own sshd uses port 22, put the BBS on 22 only after moving sshd elsewhere.

TELNET_ADDRESS=0.0.0.0:23

7. Put the web terminal behind a reverse proxy

The web listener serves the browser terminal at /, its websocket at /ws, the app's #[Get] routes (/api/status, /api/oneliners, /api/last-callers, /api/art/matrix) and static files from resources/web (WebServer.php). The page connects to wss://<host>/ws when it is loaded over HTTPS and ws://<host>/ws otherwise (app.js), so the proxy has to pass websocket upgrades for /ws.

Bind the web listener to loopback (WEB_ADDRESS=127.0.0.1:8080) and name the proxy as trusted:

WEB_TRUSTED_PROXIES=127.0.0.1

The web server ignores X-Forwarded-For and X-Forwarded-Proto unless the request comes from an address in trustedProxies. From a trusted proxy, the caller's address is the right-most X-Forwarded-For entry that isn't itself a trusted proxy, and X-Forwarded-Proto: https marks the session secure for the SC access check. Without the setting, every web caller appears to come from the proxy's address, which then counts against maxConnectionsPerAddress for all of them.

Caddy (websockets are proxied automatically):

bbs.example.org {
    reverse_proxy 127.0.0.1:8080
}

nginx:

server {
    listen 443 ssl;
    server_name bbs.example.org;
    # ssl_certificate ... ssl_certificate_key ...

    location /ws {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 1h;
    }

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

proxy_read_timeout keeps an idle websocket from being cut at nginx's 60-second default. Carrier's own idle timeout (BbsConfig::$idleTimeout, 600 seconds) still applies.

Telnet, SSH and rlogin are plain TCP and are not proxied over HTTP.

8. Block addresses

BlockAddresses is the first step of the connection pipeline. It refuses any caller whose IP matches a rule in BbsConfig::$blockedAddresses, showing "Access denied." and hanging up. The app's bbs.config.php doesn't set the list, so add it there:

// app/Config/bbs.config.php
return new BbsConfig(
    // ...
    blockedAddresses: ['203.0.113.7', '198.51.100.*', '192.0.2.0/24'],
);
Rule form Example Matches
exact 203.0.113.7 that address (IPv4 or IPv6)
prefix 198.51.100.* addresses starting with 198.51.100.
CIDR 192.0.2.0/24 that IPv4 range; CIDR rules are not applied to IPv6 callers

The port is stripped before matching. Restart the board after editing. Keep BlockAddresses::class in pipeline if you set your own pipeline.

Behind a TCP proxy

When telnet or SSH reach the board through a TCP proxy (HAProxy, nginx's stream module, Fly.io's proxy_proto handler), every caller would appear to come from the proxy. Have the proxy send the PROXY protocol header and list those listeners:

PROXY_PROTOCOL=telnet,ssh

On a listed listener the header is required: the board reads it before anything else, takes the caller's address from it, and drops connections that don't start with one. List a listener only when the proxy is the sole way to reach it, or anyone could claim any address. Both v1 and v2 headers are accepted (ProxyProtocol.php).

Repeated wrong passwords are throttled separately (Authenticator.php): 10 failures from one host within 10 minutes refuse that host until they age out, and after 3 failures on one handle every further attempt on it waits longer, up to 30 seconds. Callers are also limited to maxConnectionsPerAddress open connections each (default 8); see configuration.

9. Logs

What Where
Board log storage/logs/carrier.log, [Y-m-d H:i:s] LEVEL: message
Console log stderr while serve runs without --quiet

The board log is opened once, in append mode, when the process starts. To rotate it without a restart, use copytruncate so the open file handle keeps working:

# /etc/logrotate.d/carrier  (example)
/srv/bbs/storage/logs/carrier.log {
    weekly
    rotate 8
    compress
    missingok
    copytruncate
}

Set LOG_LEVEL=debug to log each node's detected terminal and other detail.

10. Back up

Everything worth keeping is under storage/:

Path Holds
storage/carrier.sqlite (or DB_DATABASE) accounts, messages, mail, oneliners, polls, door scores and state
storage/keys/ SSH host keys
storage/doors/ per-node drop-file directories for external doors (recreated as needed)

Copy the database with SQLite's online backup, which is safe while the board is running:

sqlite3 storage/carrier.sqlite ".backup 'backups/carrier-$(date +%F).sqlite'"

Also keep your own changes to app/, resources/ and doors/ in version control.

11. Upgrade

cd /srv/bbs
git pull
composer install --no-dev --optimize-autoloader
php carrier migrate
php carrier discovery:generate
sudo systemctl restart carrier

migrate without --fresh only runs migrations that haven't run yet. Never run migrate --fresh on a live board: it drops every table. The restart disconnects everyone, so pick a quiet hour or warn callers first. A sysop can broadcast a message from the sysop menu.