Skip to content

Updating the platform ​

Updates bring fixes and new features. Follow the same steps every time, in order, and you can always go back if something goes wrong.

15–30 minutesServer administrationDevOpsVerified against the platform code

Update at a quiet time

Pick the hour with the least trading, usually early morning UTC on a weekday. Tell users in advance with an announcement.

Back up ​

Take a fresh database and files backup right before updating. See Backups & restore.

bash
/usr/local/bin/exchange-backup.sh

Also note the current version, so you can return to it:

bash
cd /var/www/exchange
git rev-parse HEAD > ~/before-update.txt

Turn on maintenance mode ​

In Admin → Settings → General, turn on Maintenance mode. Visitors see the maintenance page, and admins keep full access to test. See General settings.

Then stop new background work while files change:

bash
php artisan horizon:pause

Get the new code ​

bash
cd /var/www/exchange
git pull
# or unzip the new release archive over the folder, keeping .env, storage/ and socket-config.json

Install dependencies ​

bash
composer install --optimize-autoloader
npm ci

If the bridges or chart service changed, update them too:

bash
(cd chart-udf && npm ci)
cd bridges && npm install && for n in ethereum bnb tron polygon solana ton; do (cd $n && npm install); done; cd ..

Update the database ​

bash
php artisan migrate --force

Read the output. If a migration fails, stop here and roll back.

Build the front-end ​

Rebuild both bundles and change the asset hash, exactly as in Building assets.

Make sure USER_ASSETS ends as "false" afterwards.

Clear caches ​

bash
php artisan optimize:clear

This clears cached configuration, routes, views and events, so the new code is used everywhere.

Restart background processes ​

Workers and long-running processes still run the old code until they restart:

bash
php artisan pm:watcher                          # applies changes to config/pm.php (new / changed services)
php artisan horizon:terminate                   # Horizon finishes its jobs, PM2 starts it again
pm2w restart storage/app/pm2/ecosystem.json     # every background service (each finishes its current pass first)
pm2w restart bridge-ethereum bridge-bnb         # each bridge that changed
sudo systemctl reload php8.3-fpm                # clears PHP's code cache

Without the restart, the workers still pick up the new code within an hour (they restart themselves hourly). You can also restart single services from Admin → Market services.

Test, then open ​

With maintenance still on, sign in as an admin and check:

  • the home page, a trade page (chart, order book, Stable connection), your wallet
  • a small test order, then cancel it
  • the admin dashboard and System Monitor

Then turn Maintenance mode off.

Less downtime ​

  • Build first, switch later. Build the new version in a second folder (for example /var/www/exchange-new), with its own vendor and compiled assets. Then run migrations, swap the folders (or a symlink that Nginx points to), and restart the processes. Users see only the last minute.
  • Check migrations before the window. Run php artisan migrate --pretend on a copy of production to see what each migration will do.
  • Test on staging. Restore last night's backup onto a staging server and do the update there first.

Rolling back ​

If the new version has a serious problem:

  1. Turn maintenance on.

  2. Return to the old code:

    bash
    git checkout $(cat ~/before-update.txt)
    composer install --optimize-autoloader
  3. If migrations ran, restore the database backup you took before updating (see Restore, step 3). Running migrate:rollback isn't safe for every migration, and orders placed after the backup would be lost either way. That's why the update starts in maintenance mode.

  4. Rebuild the front-end, clear caches and restart processes, as above.

  5. Turn maintenance off.

Don't restore while trading

Restoring a database backup removes everything that happened after it was taken: trades, deposits, withdrawals. Only restore while maintenance is on, and before reopening trading.

Owner documentation for the CryptoTech exchange platform.