Installing with the server installer

Install Structam as a systemd service on Debian, Ubuntu or the RHEL family with install.sh: steps, options, secrets, re-runs, Caddy and the hardened units.

On this page

Status. Tested: the installer run for real in an Ubuntu 24.04 systemd container (arm64) against an external PostgreSQL 18, re-run (nothing restarted, the secret key kept), with --role worker and with --uninstall; dry runs on Debian 13 and Rocky Linux 9 containers; the units verified with systemd-analyze verify (systemd 255). Not yet run: --local-postgres (the distribution's PostgreSQL packages), and an install on a real server or a RHEL-family host with systemd.

deploy/install/install.sh installs the structam binary as a systemd service on the host itself, with no containers. It needs root, systemd, and the binary for the host's CPU from the release archive KazLabs provides. It supports Debian 12 and 13, Ubuntu 22.04 and 24.04 (apt), and RHEL, Rocky Linux and AlmaLinux 9 and 10 (dnf).

Install

# PostgreSQL elsewhere (recommended for production): a file holding the connection string, mode 0600.
umask 077; echo 'postgres://structam:[email protected]:5432/structam?sslmode=verify-full' > /root/structam-db
sudo deploy/install/install.sh --dry-run --binary ./structam --public-url https://structam.example.com \
  --database-url-file /root/structam-db          # prints what it would do; changes nothing
sudo deploy/install/install.sh --binary ./structam --public-url https://structam.example.com \
  --database-url-file /root/structam-db

Or with PostgreSQL from the distribution on the same host, which must be 16 or newer (Debian 13, Ubuntu 24.04, RHEL 9 with the postgresql:16 module, RHEL 10). Debian 12 and Ubuntu 22.04 ship older releases and are refused.

sudo deploy/install/install.sh --binary ./structam --public-url https://structam.example.com --local-postgres

What it does

It prints each step as == N. Title:

  1. Packages: only with --local-postgres. It installs the distribution's postgresql; on the RHEL family it enables the postgresql:16 module stream when there is one, runs postgresql-setup --initdb and adds a scram-sha-256 loopback rule for the structam database ahead of the distribution's ident rules, after a backup of pg_hba.conf.
  2. User: the structam system user and group (no home, no shell).
  3. Settings and secrets: /etc/structam (0750 root:structam); /etc/structam/secrets holding secret_key, database_url and bootstrap_admin_password (each 0640 root:structam, generated once and never replaced by a re-run); and the env file /etc/structam/structam.env (0600 root), which names the secret files with STRUCTAM_<NAME>_FILE and holds no secret itself.
  4. Binary: /usr/local/bin/structam, replaced only when it differs; the previous one is kept as structam.previous. The new binary must run structam version before it replaces the old one.
  5. Units: structam-<role>.service and structam-migrate.service.
  6. Database schema: systemctl start structam-migrate (role all, or any role with --migrate).
  7. Service: enabled, (re)started when anything changed, and waited for until structam healthcheck passes; then structam doctor prints its checklist.

The closing message says how to sign in. Every host installed with role all or serve generates its own bootstrap_admin_password, but only the first node to start on a database without users creates the administrator, with its own password. The installer tells you to sign in with this host's password only when that password signs in and must still be changed; on a later node of a cluster it says that the administrator already exists.

Options

OptionMeaning
--binary FILEthe structam binary to install
--public-url URLthe https:// URL agents and browsers use; required for every role
--database-url-file FILEa file holding the PostgreSQL connection string
--local-postgresinstall and use the distribution's PostgreSQL on this host
--role serve or --role workercluster nodes (high availability); a worker takes the same --public-url and --trusted-proxies as the serve nodes
--listen ADDRdefault 127.0.0.1:8080 (127.0.0.1:8081 for a worker): a reverse proxy on the same host; use :8080 behind a load balancer elsewhere
--trusted-proxies LISTthe proxy or load balancer addresses, default 127.0.0.1,::1
--secret-key-file FILEthe cluster's key, on every node after the first
--replace-secret-keychange the key on purpose (rotating the secret key)
--migraterun the schema migrations on a node whose role does not by default
--no-startinstall without starting
--dry-runprint what it would do and change nothing
--uninstallremove the units and the binary; keep /etc/structam and the database

--help lists them all.

Re-runs and the secret key

Re-running the installer is safe. An env file you edited is kept, and the installer writes its own rendering beside it as structam.env.new; the service is restarted only when the binary, a unit, a setting or a secret changed.

The secret key seals every stored credential, every configuration file content and the server identity that agents pin, and the host may hold its only copy. So a re-run whose --secret-key-file holds a different key than the installed /etc/structam/secrets/secret_key (a typo, another cluster's key) stops before it changes anything; passing the same key again is fine. To change the key on purpose, follow rotating the secret key and add --replace-secret-key: the installer keeps the old key as secret_key.previous-<time> and as secret_key_previous, names the latter as STRUCTAM_SECRET_KEY_PREVIOUS_FILE and restarts the node, so every value sealed with the old key still opens. Once every node has the new key, run structam rotate-secret-key once, on one node:

sudo sh -c 'set -a; . /etc/structam/structam.env; set +a; runuser -u structam -- structam rotate-secret-key'

Then, on every node, delete /etc/structam/secrets/secret_key_previous and at once re-run the installer without --secret-key-file: it drops the line and restarts the node. Until then a restart of that node fails on the missing file. A second --replace-secret-key is refused while secret_key_previous exists, because the keyring holds one previous key only.

A reverse proxy on the same host

The installer opens no firewall port and installs no reverse proxy. With Caddy on the same host, using the Caddy configuration from the release archive:

sudo apt-get install caddy                      # or dnf install caddy (EPEL / COPR)
sudo cp deploy/caddy/Caddyfile /etc/caddy/Caddyfile
sudo systemctl edit caddy                       # [Service]
                                                # Environment=STRUCTAM_SITE=structam.example.com
                                                # Environment=STRUCTAM_UPSTREAMS=127.0.0.1:8080
                                                # Environment=STRUCTAM_TLS_MODE=acme
sudo systemctl restart caddy

The Caddy configuration terminates TLS, balances over the nodes listed in STRUCTAM_UPSTREAMS with a health check on /readyz, passes the agent WebSocket, does not buffer event streams, and writes an access log without query strings. STRUCTAM_TLS_MODE is internal, acme or byo (it then reads /etc/caddy/tls/cert.pem and /etc/caddy/tls/key.pem).

The systemd units

UnitRuns
structam-all.servicestructam all: API, web UI, agent gateway and full worker pools (one node)
structam-serve.servicestructam serve (cluster)
structam-worker.servicestructam worker (cluster)
structam-migrate.servicestructam migrate, started by the installer and for upgrades

The units run as the unprivileged structam user with no capabilities, a read-only file system, a system-call filter and the rest of systemd's sandboxing (systemd-analyze security structam-all rates it 1.4, "OK"). The stop timeout is 45 s, which covers the drain (stopping a node). Logs go to the journal:

journalctl -u structam-all -f

A unit that fails 10 times in 5 minutes is not restarted again: fix the cause, then systemctl reset-failed structam-all. Waiting for an unreachable database is not a failure (the process stays up).

Questions the docs do not answer?

Ask the people who build Structam. Installation media and licences come from KazLabs.

Talk to us