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.
What changed
- 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.
- cd and git commands removed. The release macros fetch your code into the new release, and the script runs from there.
- PHP-FPM reload removed. $ACTIVATE_RELEASE() reloads PHP for you.
- 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.
- npm ci falls back to npm install for projects without a package-lock.json.
- 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.