elements
Start Docs Blog Demos UI Pricing
Elements Manual
  • Getting Started
  • CLI
  • Build
  • Browser
  • Packages
  • TypeScript
  • Elements HTML
  • Assets
  • RPC
  • Router
  • Session
  • Database
  • Migrations
  • LiveTable
  • Channel
  • Jobs
  • Email
  • Payments
  • JSON
  • Async
  • Style
  • UI
  • JSOC
  • Config
  • Tests
  • Logs
  • Deploy
    • Setup
    • Sizing
    • AWS
    • DigitalOcean
    • Email Setup
    • CDN
    • Walkthrough
    • Domain
    • What Deploy Does
    • Environments
    • Load Balancer
    • Operations
    • Machines
  • Editors
  • Recipes
  • Licenses
  • Issues
  • Changelog
Manual / Deploy/ What Deploy Does

What Deploy Does

elements man deploy/what-happens

On This Page

  • What elements deploy Does
  • elements deploy -json
  • What Makes Deploys Fast
  • Provisioning Details

The steps elements deploy runs, its -json output, why it is fast, and how machines are provisioned.

What elements deploy Does

Each phase is sequential. An error in any phase aborts the deploy. The previous release keeps serving traffic until the new release is fully ready.

  1. Local prep: validate services, run preDeploy commands, build each service binary.
  2. Provision: verify Linux + systemd, create the elements system user, install Elements, bring up the Postgres cluster, create the project dir.
  3. Connect: open SSH tunnel to each machine's deploy server.
  4. License: check out a license token on each machine.
  5. Sync: diff manifest, transfer only changed files via project-server-to-project-server protocol.
  6. Build: compile, package install, asset emit on each machine.
  7. Migrate test db: run pending migrations against the test db (first machine only).
  8. Test: run all tests on each machine.
  9. Migrate app db: run pending migrations against the app db (first machine only).
  10. Release: atomically swap .elements/release to point at the new build.
  11. Update state: record successful deploy in the per-machine state file.

The release in step 10 is the "go-live" point. The old release continues serving until the new release directory is fully written and the swap completes.

elements deploy -json

Run elements deploy with -json from an agent. The command returns structured JSON, exits cleanly, and never opens a TUI. Without -json, elements deploy runs as a TUI and buffers when piped through tail, head, or less.

Terminal
elements deploy production -json elements deploy staging -json

elements will not deploy if there are local build errors.

Deploying is one command: run elements deploy -json, read the diagnostics, report them. The diagnostics cover both the local build and every machine, so they are the only place to look when a deploy fails. Do not SSH to a machine to confirm what a diagnostic already says, and do not go checking systemd units, /elements, dns, or the clock. Report the diagnostics as written.

Every diagnostic carries a hosts field, rendered as a [<host>] tag at the end of the message in the TUI. Use it to triage where the failure happened:

  • No hosts field (and no [<host>] tag in the TUI): the failure is local. Fix it in the source tree; the deployment machine was never involved.

  • hosts: ["production0"] (rendered as [production0] in the TUI; the list can contain one or more machine names): the failure happened on those machines after the source was synced. The message is the machine's own report, relayed over the tunnel. Fix the cause in the source tree or in config.jsoc and deploy again.

A local failure:

Local failure
{ "diagnostics": [ { "category": "error", "message": { "data": "Type 'string' is not assignable to type 'number'." }, "path": "app/pages/home/services.ts", "loc": { "line": 12, "column": 18 } } ] }

A remote failure:

Remote failure
{ "diagnostics": [ { "category": "error", "message": { "data": "migration 20260514120000-add-orders-table.migration.sql failed: relation \"orders\" already exists" }, "hosts": ["production0"] } ] }

A successful deploy returns an empty diagnostics array.

What Makes Deploys Fast

A deploy, like a local build, does only the work the changed files require. The deploy machine runs the same Elements build server you run locally. The two build servers compare their file manifests over the SSH tunnel and transfer only the files that differ, so the deploy does the smallest set of steps required to produce a correct release.

  • Source diffing is fast. The local server has a live manifest of every file in the build graph. So does the remote server. The deploy diffs the two manifests and transfers only the files that differ.
  • The remote build does the minimum work required. The remote build server stays alive across deploys. When new files arrive, it does only the work necessary to produce a correct release.

The remote build server keeps its build state across deploys. A deploy transfers the changed source files, compiles incrementally on the deployment machine, and swaps the release.

A typical incremental deploy:

  1. Local build does only the work the changed files require.
  2. File sync transfers only the files whose content hash has changed since the last deploy.
  3. Remote build does only the work the changed files require, on the deployment machine.
  4. Tests run only for the changed test subgraph.
  5. Release swap is an atomic directory rename, with no restart pause and no warm-up.

A deploy succeeds only once the app is up on every machine. The app is up when its server is listening. A program that is not an Elements app is up once its main module has run without throwing, or when it calls reportReady() from elements:runtime after calling deferReady() while its main module ran. If the app exits before it is up, the deploy fails with its exit code and its last lines of output. If it is still not up 60 seconds after the release, the deploy fails the same way. A hot reload that throws while the new code loads fails it too.

When the Elements version changed, the deploy restarts elements-app and elements-job and waits for systemd to report them active. Otherwise it starts elements-app if it is not running, so an app unit that was down comes up on the new release.

The load balancer has its own version. The deploy restarts elements-lb only when that version changed, so most Elements upgrades leave it running with its listeners and certificates.

Provisioning happens only on the first deploy to a fresh machine. After that Elements is installed, the system user exists, the systemd units are installed, the Postgres cluster is running, and the build server is running.

Provisioning Details

What Elements does on the first deploy to a new machine:

  1. SSH in as the configured user.
  2. Verify the OS is Linux with systemd and curl available.
  3. Create the dedicated service users (each Elements service runs as its own low-privilege user; no service runs as root). The SSH user joins their shared elements group so it can read the app without sudo.
  4. Install the Elements binaries at /elements/bin/.
  5. Bring up the bundled Postgres cluster (data directory /elements/db).
  6. Create the app directory at /elements/app/. The path does not depend on your project's name: a machine runs one app, and a different project deployed to it replaces the app. Its database stays in the cluster.
  7. Install OS packages from deploy.packages via apt.
  8. Set up the systemd units elementsd, elements-app, elements-lb and elements-job, plus one unit per custom service, named after it.
  9. Start the built-in load balancer with automatic SSL.

State is recorded in a per-machine deploy state file. Subsequent deploys read the state and skip already-completed steps. Upgrading the Elements version triggers a re-install of the Elements binaries.

Prev DomainNext Environments
Product
Manual Pricing Compare
Company
History Contact
Legal
Privacy Policy Acceptable Use Terms License Agreement
© Elements Dev Corporation 2026