Sari la conținutul principal
FreeThree checks for your projectUptime, accessibility, SEO and cookie checks for your project
Menu

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.

RuleA deploy starts whenTypical use
BranchYou push to the branch the environment follows.Staging
Release tagYou push a tag that matches the pattern of the environment.Live
By handYou 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

  1. Build. Tilizy fetches the commit and runs hooks.build in 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.
  2. Database changes. hooks.deploy runs, 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.
  3. Readiness. A check proves that the new release starts against the updated database.
  4. Switch. Files listed under plugins.prune are 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.
  5. Health check. Tilizy checks that the website answers, and lifts the maintenance page if it was shown.
  6. After the switch. hooks.post_deploy runs inside the running website.

Your hooks

HookRunsPut hereIf a command fails
hooks.buildBefore the switch, in the build containerInstalling dependencies, building assetsIt is tried up to three times. Then the deploy fails and nothing changes.
hooks.deployBefore the switch, in the build containerDatabase updates, configuration importThe deploy fails at once.
hooks.readinessAfter the deploy hooks, before the switchOne command that proves the release startsThe deploy stops. The previous release keeps serving.
hooks.post_deployAfter the switch, in the running websiteContent imports, cache warm-up, reindexingThe 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_NAME run without a maintenance page.
  • Any pending hook_update_N shows 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.