Services
Declare the database, cache and search engine of your website in .tilizy/services.yaml, connect to them and upgrade their versions.
On this page
Services are the programs your website depends on: the database, the cache, the search engine. You declare them in .tilizy/services.yaml, next to the project file. Every environment, and the copy on your computer, gets its own instance of each service you declare.
The file
services:
db:
type: mariadb
version: "11.8"
persistent: data
cache:
type: redis
version: "8.10"
| Key | What it does |
|---|---|
The name (db, cache) | You choose it. Your application reaches the service under this name as its host name. Use letters, digits and underscores, and do not start with a digit. The name webserver is reserved. |
type | The kind of service. Required. |
version | The version to run. Required. Put it in quotes so that "11.8" stays text. |
persistent | A name for the storage that keeps the data of the service. Leave it out for a cache whose content may be lost. |
The versions in the example show the shape of the file. Run tilizy service:add to see the versions you can choose today.
Available types
| Purpose | Types |
|---|---|
| Databases | mariadb, mysql, postgres, mongodb, clickhouse |
| Caches | redis, valkey, memcached |
| Search | solr, meilisearch, typesense |
| Queues and live updates | rabbitmq, mercure |
A type that is not in the list is refused when the file is read, so a typing error cannot ship a broken setup. Some types take extra keys, for example the cores and configuration sets of Solr. tilizy app:validate tells you when a key is missing or not accepted.
Add, list and remove services
-
See what you can add. Without a type, the command lists every available service with its versions:
tilizy service:add -
Add one. The command writes it into
.tilizy/services.yamlwith a conventional name and a default version:tilizy service:add redisPin a version, or choose the name yourself:
tilizy service:add redis@7tilizy service:add postgres db -
Check what is declared. The output lists name, type, version and storage for each service:
tilizy service:list -
Commit the file and deploy. The service exists on an environment after that environment's next deploy.
To take a service out of the file again:
tilizy service:remove search
Connect to a service
Inside an environment, your application reaches each service by its name. The platform passes the connection details to your application as environment variables named after the service in capitals, for example DB_HOST and DB_PASSWORD. You do not write passwords into the repository.
To look inside a service yourself, open its own client. This starts the SQL shell, redis-cli, psql or mongosh, depending on the type:
tilizy service:cli cache
Without a flag this opens the service of the copy on your computer. Add -e <branch>, --staging or --prod for a hosted environment. Services you reach only over HTTP, such as Typesense, have no interactive client.
Data and deploys
An ordinary deploy does not touch your services. The database and the cache keep running, with their data, while the code is switched. That is what lets code deploys go live without downtime.
Upgrade a version
-
Upgrade on your computer first. The command makes a dump of the database, rewrites
.tilizy/services.yaml, restarts that one service on its existing data and runs the upgrade step of the database engine:tilizy service:upgrade db@12.3Leave out the version, or the name as well, to pick from a list.
-
Test your website locally.
-
Commit
.tilizy/services.yamland deploy. The deploy notices that the version of the database engine has changed. It takes a backup, shows the maintenance page, restarts the database on the new version and finishes the upgrade.
Warning: A change of database version takes your website offline for a short time on each environment it is deployed to. Plan it for a quiet moment. The backup taken before the deploy is your way back.
Limit what a service may use
Services share the processor and memory of your server with the website. Set a limit per service type in the project file:
resources:
redis:
mem: 256m
What can go wrong
- The file is refused. The type is misspelled, the version is missing or the name contains a character that is not allowed. The message names the service.
- The upgrade does not reach live.
service:upgradechanges only the copy on your computer. Live changes when you commit the file and deploy. - A service restarts during a deploy. When Tilizy has published a security update for the software of a service, the next deploy restarts that service on the patched version. This is a brief restart.
Next: Environments and Backups and restore.