Skip to content

Updating Tradehall

Tradehall checks GitHub for new releases once a day. Staff allowed to “See which version is running and install updates” (system.updates, which owners have) see a banner on the dashboard and the release notes under Settings > About and updates. How the update gets installed depends on how Tradehall was installed.

Install Update from the settings page Automatic updates
One-line install on a server Yes: the updater backs up, restarts, and rolls back on failure Yes
Render, Coolify, Dokploy, and other platforms with a deploy hook Yes, through the platform’s deploy hook Yes
DigitalOcean App Platform, Fly.io, Railway No: redeploy from the platform (see deploying.md) No
Docker Compose by hand, Kubernetes No: change the image tag yourself, or let Renovate do it No

deploy/install.sh installs /opt/tradehall/update.sh next to compose.yml and .env, and a systemd path unit, tradehall-update.path, that runs it when Tradehall asks for an update. Servers without systemd get a cron entry in /etc/cron.d/tradehall-update instead.

Tradehall never touches Docker from inside its container, and doesn’t get the Docker socket. When an owner presses Update to x.y.z, Tradehall writes the version to /opt/tradehall/updater/request.json. The path unit starts update.sh, which:

  1. Downloads the release’s image. If that fails, nothing changes.
  2. Backs up the database with Tradehall’s own backup command, so the backup goes wherever Settings > Backups sends backups (the storage volume or your bucket). If the backup fails, nothing changes.
  3. Downloads the release’s compose.yml and update.sh, when the repository is public, so the server’s files match the release.
  4. Pins TRADEHALL_VERSION in .env to the new release and restarts the containers. The app runs new migrations as it starts, and the worker and scheduler wait for them.
  5. Waits up to 10 minutes for the app to report healthy and checks that the worker and scheduler stay up.
  6. If anything in steps 4 or 5 fails, puts the previous image and compose file back and starts them again. Migrations always leave the schema usable by the previous release (see releasing.md), so this is safe one release back.

The settings page follows along, shows the updater’s log, and reloads when the new version answers. Tradehall is unavailable for a minute or two while the containers restart.

Under Automatic updates, choose Bug-fix releases only (0.4.1 to 0.4.2) or Every release except a new major version, and an hour of the day. The scheduler starts the update during that hour once a matching release is out. Each release is tried once: if it rolls back, Tradehall leaves it for an owner to look at, and the dashboard says what happened for three days.

Automatic updates never install a prerelease or a new major version.

Terminal window
sudo /opt/tradehall/update.sh 0.4.2 # update to a release
sudo /opt/tradehall/update.sh --rollback # go back to the version before the last update that worked
sudo /opt/tradehall/update.sh --pending # run the update Tradehall asked for now

--skip-backup skips the backup, for when Tradehall itself won’t start. --allow-downgrade installs an older release than the running one; the settings page can only ask for newer ones. Only one update runs at a time.

Running install.sh again still works as an update, and it also updates update.sh and its units.

If the settings page says the server hasn’t picked up the update after two minutes, check the updater:

Terminal window
systemctl status tradehall-update.path tradehall-update.service
journalctl -u tradehall-update.service

The last run’s log is /opt/tradehall/updater/update.log, and its result is /opt/tradehall/updater/status.json. To turn the updater off, run systemctl disable --now tradehall-update.path, or install with TRADEHALL_UPDATER=off.

If the new version doesn’t start and the previous one doesn’t either, the updater stops and says so. The backup it made first is listed by backup:list. To restore it:

Terminal window
cd /opt/tradehall
docker compose stop worker scheduler app
docker compose run --rm app backup:list
docker compose run --rm app backup:restore --force <name>
docker compose up -d

Set TRADEHALL_DEPLOY_HOOK to the platform’s deploy hook URL, and Install updates appears on the settings page. Tradehall calls the hook when an owner presses Deploy x.y.z, or at the automatic update hour. The platform then deploys the way it always does: it starts the new version, checks it, and keeps the old one running if it fails. Its dashboard shows the deploy.

Platform Settings
Render TRADEHALL_DEPLOY_HOOK is the service’s deploy hook (Settings, Deploy Hook). Tradehall adds imgURL with the release’s exact image, so the service moves to that tag.
Coolify TRADEHALL_DEPLOY_HOOK is the resource’s deploy webhook (Webhooks), TRADEHALL_DEPLOY_HOOK_TOKEN an API token with only the deploy permission, and TRADEHALL_DEPLOY_HOOK_METHOD=GET. Keep the image on :latest.
Dokploy, and anything else with a webhook TRADEHALL_DEPLOY_HOOK is the deploy webhook URL. Keep the image on :latest.

Tradehall sends {"version": "...", "image": "..."} as the body, and the token as Authorization: Bearer ... when TRADEHALL_DEPLOY_HOOK_TOKEN is set. Treat the hook URL like a password: anyone with it can redeploy the service.

DigitalOcean App Platform, Fly.io, and Railway need an API token with wide access to redeploy, so Tradehall doesn’t offer it there. Redeploy from the platform instead.

Tradehall doesn’t update itself under Kubernetes. If Flux or Argo CD manages the cluster, the app changing its own deployment would fight with Git. Pin the image to a release tag and let Renovate open the pull request.

Variable Meaning
TRADEHALL_UPDATER_DIR The folder shared with update.sh. deploy/compose.yml sets it to /app/updater.
TRADEHALL_IMAGE In .env on a server: the image without its tag, for a mirror or your own build.
TRADEHALL_UPDATE_TIMEOUT Seconds update.sh waits for the containers to report healthy (default 600).
TRADEHALL_DEPLOY_HOOK A hosting platform’s deploy hook URL (https only).
TRADEHALL_DEPLOY_HOOK_TOKEN Sent as a bearer token with the hook, when set.
TRADEHALL_DEPLOY_HOOK_METHOD POST (default) or GET.