Deploys and releases
Understand what starts a deploy, the steps it goes through, where your hooks run and when visitors see a maintenance page.
On this page
A deploy turns one commit of your repository into a release and makes it the running website. Tilizy builds every release beside the running one and switches to it in one step, so visitors never see a half-deployed site. This page explains what starts a deploy, its steps, where your hooks run, and when visitors see a maintenance page.
What triggers a deploy
Each environment has its own rule. You set it in the portal.
| Rule | A deploy starts when | Typical use |
|---|---|---|
| Branch | You push to the branch the environment follows. | Staging |
| Release tag | You push a tag that matches the pattern of the environment. | Live |
| By hand | You ask for it, in the portal or with tilizy app:deploy. | A preview |
For deploying by hand, see Deploy from the terminal. Deploys of one environment run one after another, never at the same time.
Waiting for your tests
An environment that deploys by tag can wait for the pipeline of that tag. By default the live environment does not wait: the deploy starts at once, and if the pipeline fails afterwards your team is notified and can go back in one step. Other environments wait by default, and refuse the release when the pipeline fails or no result arrives in time. You can change this for each environment.
The steps of a deploy
- Build. Tilizy fetches the commit and runs
hooks.buildin a build container, away from the running website. The database has not been changed yet. Build commands of your declared processes run after your build hooks. - Database changes.
hooks.deployruns, also in the build container. If database-structure changes are pending, the maintenance page is shown from this step until the health check has passed. - Readiness. A check proves that the new release starts against the updated database.
- Switch. Files listed under
plugins.pruneare removed from the release just before it goes live. Then the new release becomes the running website in one step. Declared processes are restarted on the new code, and the deploy waits until they report ready. - Health check. Tilizy checks that the website answers, and lifts the maintenance page if it was shown.
- After the switch.
hooks.post_deployruns inside the running website.
Your hooks
| Hook | Runs | Put here | If a command fails |
|---|---|---|---|
hooks.build | Before the switch, in the build container | Installing dependencies, building assets | It is tried up to three times. Then the deploy fails and nothing changes. |
hooks.deploy | Before the switch, in the build container | Database updates, configuration import | The deploy fails at once. |
hooks.readiness | After the deploy hooks, before the switch | One command that proves the release starts | The deploy stops. The previous release keeps serving. |
hooks.post_deploy | After the switch, in the running website | Content imports, cache warm-up, reindexing | The deploy is reported as failed. The new release stays live. |
Work that changes the structure of the database belongs in hooks.deploy. Slow work that is safe while the site is serving belongs in hooks.post_deploy. On Drupal, cache changes made in the build container do not reach the running website, so a content import placed in build or deploy leaves visitors with stale pages.
Zero downtime, and the short maintenance page
A deploy that changes only code or content goes live without downtime. The running website is not restarted: requests that arrive after the switch are answered by the new release.
A deploy pauses the website only when it has to change the structure of the database. Visitors then see a maintenance page while hooks.deploy runs and the release is switched and checked. That takes seconds, as long as hooks.deploy holds nothing slow.
Note: PrestaShop runs on Apache by default. An environment served by Apache is restarted on each deploy instead of being switched in place.
On Drupal, Tilizy looks at the pending updates:
- Updates written as
hook_post_update_NAMErun without a maintenance page. - Any pending
hook_update_Nshows the maintenance page.
Rehearsing database updates
With hooks.rehearse_migrations: true, pending updates first run on a temporary copy of the database. An update that fails is refused, and live is not touched. An update that only adds things, such as a new table or an optional column, goes live without a maintenance page.
Warning: The rehearsal runs your update code twice. Only the database is a copy. An update that writes files, sends email or calls another system would do so twice. Read your update code before you switch this on.
What can go wrong
- Removing a database column. The previous release keeps running until the switch. If an update drops a column that the old code still reads, the old release fails for that time. Remove a column over two releases: the first stops using it, the second drops it.
- Scheduled jobs keep running during a deploy. An update that copies live data into a new structure can miss what the old release still writes. Let the update create the structure only, and let the new code fill it on first use.
- Changes made on the live site are overwritten. A Drupal configuration import replaces live configuration with what is in the repository. Check first with
tilizy drupal:config:status. See Framework commands. - A success message is not proof. A queued deploy does not mean the release is serving. Check the result and open the website.
Next: Roll back and Deploy from the terminal.