Kiln
Get started
Free tool · no account needed

Convert a Forge deploy script to zero-downtime

Paste a site’s deploy script from Forge. You get the zero-downtime version, every change explained, and the things to check before you switch.

Zero-downtime version of the example
# Build the new release in its own folder. The live site keeps serving the old one.
$CREATE_RELEASE()
cd $FORGE_RELEASE_DIRECTORY
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
npm ci || npm install
npm run build
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
fi
# Every step above succeeded: switch the site to the new release and reload PHP.
$ACTIVATE_RELEASE()
# Restart queue workers so they pick up the new code.
$RESTART_QUEUES()

+ added~ changed or moved

Converted on our server and never stored. Remove any secrets before pasting.

What changed

  1. Release macros added. $CREATE_RELEASE() builds each deploy in a new folder, and $ACTIVATE_RELEASE() switches the site to it only when every step has succeeded.
  2. cd and git commands removed. The release macros fetch your code into the new release, and the script runs from there.
  3. PHP-FPM reload removed. $ACTIVATE_RELEASE() reloads PHP for you.
  4. Queue restarts became $RESTART_QUEUES(). Forge restarts queue workers and Horizon once the new release is live, so queue:restart and horizon:terminate aren’t needed.
  5. npm ci falls back to npm install for projects without a package-lock.json.
  6. Comments added. Each group of commands is labelled with what it does and why it runs there.

Check before you switch

  • Uploads must be shared. Add folders kept out of Git, such as storage/app/public or public/uploads, to the site’s shared paths in Forge, or each release starts empty.
  • Cron jobs and workers need the new path. Commands pointing at /home/forge/example.com must point at /home/forge/example.com/current, the folder that always holds the live release.
  • Zero-downtime is chosen when a site is created. Forge can’t switch an existing site over, so converting means creating a new zero-downtime site and moving the domain to it.

Convert every site on a server at once

Kiln converts each site’s script, shares its uploads, fixes cron paths, then moves the whole server with zero downtime. £15 a server.

Try the live demo See how it works