CControxity Docs
GuidesReferenceHTTP APIOpen Controxity
How to

Deploy, and know it's running

How a new version reaches each place, from "the team deploys it" to a GitHub Actions run, and how Controxity knows it arrived.

Setting up a place from the start (a server, a web page, an Android or iOS app), and every way a version gets there, with pictures: Every place, step by step.

The place's own report decides#

A version has arrived when the place says it runs it (or a later one), whoever deployed it and however. So the simplest way works: deploy the way you always have, and Controxity sees the new version in the next report.

One deploy command, for every way#

Every product gets the same deploy, whoever presses the button. npx controxity init writes it into controxity.yml (for a compose file, docker compose up -d --build); change it if your app deploys differently:

deploy:
  production: docker compose up -d --build
  health: https://shop.example/health

Then, in the product's folder:

npx controxity deploy

It puts the commit live exactly as committed: it runs your command in a clean copy of that commit (kept in .git/controxity/), so files you're still editing never go live and the version is always one commit. Your ignored .env files are copied in, fresh for each deploy, and the folders your compose file mounts are linked in, and compose keeps your project's name, so the same containers are updated. Then it waits for health, goes back to the last commit that deployed if the new one isn't healthy, and tells Controxity which commit is live (with the key from your .env). Your app reports the version without being told: the SDK reads the controxity-release.json it writes.

Option
--commit REFAnother commit than the one checked out.
--channel stagingThe staging command instead.
--dry-runSay what it would do.
--only-pushedRefuse a commit that isn't on the repository's main. The helper always does.

What your command gets#

VariableHolds
CONTROXITY_COMMITThe full commit being deployed.
CONTROXITY_CHANNELproduction or staging (for a phone place's helper: update-production or build-production).
CONTROXITY_VERSIONThe version's number, when one was given (--version, or the version Controxity asks the helper for). Without one, an app that names its own versions keeps doing so.
CONTROXITY_PLATFORMFor a phone place's helper: android or ios.
CONTROXITY_CLIThe command line's own file, for node "$CONTROXITY_CLI" ….
COMPOSE_PROJECT_NAMEYour checkout's folder name, when your compose file names none, so the same containers are updated.

It runs in the clean copy, with sh -c. A script named as sh scripts/deploy.sh whose first line asks for bash (#!/usr/bin/env bash) is run with bash, so [[ ]] and set -o pipefail work. node is on its path, the one the helper runs with.

Exit codes. 0 = done. 3 = it said no on purpose (say why on its last lines): nothing is rolled back, and Controxity shows the reason (a phone update script uses it for "this needs a new store build"). Anything else = it failed.

When it fails. If your command fails or the app isn't healthy, it goes back to the last commit controxity deploy put live there. The first deploy has none, so a failure then just stops: whatever ran before stays as it was. A failure in your own checks (a test that crashed, the network dropping during an install) is a failure like any other: run it again once the cause has passed.

Containers that mount the whole folder. The mounted folders are links in the clean copy, pointing at your checkout (the .env files are real copies, so a deploy that sends them on with rsync -a or scp sends the file). A compose volume such as ./builds:/srv works, since Docker follows the link. A container that mounts the whole folder (-v "$PWD":/app) sees only the link, which points at a path it doesn't have: mount the real folder too, for example -v "$(readlink -f builds)":/app/builds.

The helper, in one command#

To deploy when someone presses Deploy in Controxity, set the place to Helper on the server, then on that server, in the product's folder:

curl -fsSL https://your-controxity/sdk/cli.js -o /tmp/controxity.js
node /tmp/controxity.js helper install --place "shop live" --start

That writes the helper to ~/.config/controxity/helpers/<product>-<place>/ (outside your code, so a pull can't change what deploys it; it checks its own copy before each start) and a systemd user service, controxity-<product>-<place>, and starts it. Each minute it asks Controxity for a version; when there is one it runs controxity deploy --only-pushed for that commit and says how it went. Controxity sends only a version and a commit, never a command, and the helper checks both look like one. Run loginctl enable-linger $USER once, so it keeps running while nobody is signed in.

Its key. The line Setup makes carries the place's own key, kept beside the helper in a file only you can read. Without one, the helper uses CONTROXITY_KEY from your app's .env files (a server place's key, dep_…). A refused key is said in its log: make the line again in Setup.

It never touches your working folder. Each version is deployed from the helper's own copy of the code (.git/controxity/deploy-production/), checked out at that exact commit. Whatever branch you or your team are on, with whatever isn't committed, nothing of it is deployed, and a deploy never waits for the folder to be on main. It deploys only commits on a remote's main (with two remotes, either one's); a commit no remote has comes from Controxity's copy of the code, so the machine needs no access to GitHub or GitLab. One deploy at a time per checkout: another waits up to 20 minutes.

It keeps itself up to date. When Controxity has a newer helper, the helper takes it between jobs by itself (it restarts with the new one). Nothing to do.

Moving it, or making it again. Press Make the install command again (Setup, or How new versions get there) and run the new line: on the same machine it replaces the service of the same name; on another machine, stop the old one there (systemctl --user disable --now controxity-<product>-<place>). A service of that name that isn't this place's helper (one written by hand) is never replaced: the new one gets a number, so stop and remove the old one first.

Watching it. systemctl --user list-units "controxity-*" lists the helpers on a machine; journalctl --user -u controxity-shop-live -f shows one at work.

From a deploy script of your own#

If a place already deploys with a script of yours run by a hand-written helper, move it to the standard one:

  1. Put your deploy in controxity.yml (deploy: production: bash scripts/deploy-from-controxity.sh and health:). It runs in the helper's copy of the code, so it mustn't cd to your checkout, fetch, merge or check which branch is out: the helper did all that. Keep what only your app knows in it (waiting until users aren't mid-upload, checking the version after).
  2. Merge that to main.
  3. Stop the old helper's service and remove its unit file, so the name is free.
  4. Setup → Controxity's helper does it → Make the install command, and run the line in the checkout.
  5. Send the place a version. The first run in a new copy takes longer (packages to install).

Every command#

The command line is one file, at https://your-controxity/sdk/cli.js (and npx controxity once it's on npm). node cli.js help prints this.

CommandWhat it does
deployPuts a commit live as committed (above). --commit REF, --channel staging, --dir PATH, --dry-run, --only-pushed, --no-rollback.
helper install --place "NAME"Sets up the helper for a place on this machine. --app "PRODUCT" (Setup's line gives it), --dir PATH, --start. A phone place's line adds --update CMD and --build CMD, and --files DIRS when the build writes its files somewhere it doesn't name.
eas-build ios (or android)A store build in Expo's cloud: runs eas build, waits, downloads the file to ~/controxity-builds/ and names it. --dir APP (the app's folder), --profile NAME (default production), --out DIR. Needs EXPO_TOKEN, here or in the app's .env. See Phone apps.
releaseTells Controxity about a release and sends its source maps, from CI. --version, --commit, --branch, --maps DIR, --maps-prefix P, --strict, --json. See Send source maps.
initWrites a first controxity.yml and, when there's none, AGENTS.md. --dry-run, --force.

Choose a way, per place#

Where it runs → How new versions get there:

WayWhat happens
The team deploys itThe default. Nothing is sent: you deploy as you always do.
GitHub Actions workflowControxity starts your own workflow (workflow_dispatch, with version, commit and place) and follows its run. Download a starting workflow gives one to fill in. Nothing to install.
GitLab pipelineControxity starts your project's pipeline with the version and commit, and follows it.
Helper on the serverA small script on your server asks Controxity each minute for a version to deploy, and runs your own deploy command there. Your server calls out; nothing is opened to it, and Controxity holds no key to it.
Deploy webhookControxity posts {"event": "deploy", "version", "commit", "place", …} to your hosting platform's deploy hook or your CI, signed with X-Controxity-Signature.
Deploy command, run hereYour deploy: command in controxity.yml, run on Controxity's server. Only for the server's own company.

Staging first, then production#

With a staging place, a fix goes there first. Promote to production sends the same commit, and is refused if it failed on staging or its error came back there. New problems on staging also stop it until a developer looks.

Production always waits for the yeses your product asks for: see Approvals and roles. Freeze windows (Defaults → Rules and safety) hold production deploys for a launch or a Friday afternoon; an admin can go ahead anyway.

Phones#

A phone app's store build and over-the-air updates have their own rules: see Phone apps. A rollout in stages widens while its health holds and stops by itself when it looks worse.

Controxity 1.132.0These pages are in the repository: docs/site