fix(general): Only add database service if available

This commit is contained in:
jeanluc
2022-05-11 11:08:48 +02:00
parent a2ddc1c1a1
commit 06bb925fb3
2 changed files with 2 additions and 3 deletions

View File

@@ -45,10 +45,9 @@ Special notes
* The formula is currently Linux/systemd-centric. It should be relatively easy to provide the correct parameters and service file for other platforms though. * The formula is currently Linux/systemd-centric. It should be relatively easy to provide the correct parameters and service file for other platforms though.
* Since the formula skips the web installer, you will need to provide at least the database configuration. * Since the formula skips the web installer, you will need to provide at least the database configuration.
* You can optionally specify the secrets, but they can be autogenerated by Salt as well. In that case, they will be saved in a grain value. * You can optionally specify the secrets, but they can be autogenerated by Salt as well. In that case, they will be saved in a grain value.
* Secrets and database config will be written to the global config file, the rest into ``custom/conf/app.ini``.
* All the paths are modifiable, find them in ``lookup:paths``. You should not need to set the corresponding values in your config, they are added automatically. * All the paths are modifiable, find them in ``lookup:paths``. You should not need to set the corresponding values in your config, they are added automatically.
* If Gitea requires mounts for some of the paths, you can specify them in ``service:requires_mount`` as a list. * If Gitea requires mounts for some of the paths, you can specify them in ``service:requires_mount`` as a list.
* If Gitea requires a local service unit (e.g. database server), specify it/them in ``service:wants`` as a list. * If Gitea requires a local service unit (e.g. Redis server), specify it/them in ``service:wants`` as a list. This formula will do its best to automatically add a locally running database service to this list.
RST mod RST mod
^^^^^^^ ^^^^^^^

View File

@@ -101,7 +101,7 @@
{%- if mapdata.config | traverse("database:db_type", "mysql") in ["mysql", "postgres", "mssql"] -%} {%- if mapdata.config | traverse("database:db_type", "mysql") in ["mysql", "postgres", "mssql"] -%}
{%- set db_type = mapdata.config | traverse("database:db_type", "mysql") -%} {%- set db_type = mapdata.config | traverse("database:db_type", "mysql") -%}
{%- if db_type not in mapdata.service.wants -%} {%- if db_type not in mapdata.service.wants and salt["service.available"](db_type) -%}
{#- MariaDB usually provides `mysql.service` as well. -#} {#- MariaDB usually provides `mysql.service` as well. -#}
{%- do mapdata.service.wants.append(db_type) -%} {%- do mapdata.service.wants.append(db_type) -%}
{%- endif -%} {%- endif -%}