|
| 1 | +.. _tcm_configuration: |
| 2 | + |
| 3 | +Configuration |
| 4 | +============= |
| 5 | + |
| 6 | +.. TODO: write specific configuration tutorials for http, security, logging, and so on. |
| 7 | +
|
| 8 | +This topic describes the |tcm_full_name| configuration model. For the complete |
| 9 | +list of |tcm| configuration parameters, see the :ref:`|tcm| configuration reference <tcm_configuration_reference>`. |
| 10 | + |
| 11 | +Parameter groups and names |
| 12 | +-------------------------- |
| 13 | + |
| 14 | +|tcm_full_name| configuration parameters are grouped by the functions that they |
| 15 | +affect. There are the following groups: |
| 16 | + |
| 17 | +* HTTP |
| 18 | +* logging |
| 19 | +* configuration storage |
| 20 | +* security |
| 21 | +* add-ons |
| 22 | +* limits |
| 23 | +* |tcm| running mode |
| 24 | + |
| 25 | +for better structure, some groups have nested groups. For example, there are ``tls`` |
| 26 | +and ``websession-cookie`` groups within ``http`` that define TLS encryption and |
| 27 | +cookie settings. |
| 28 | + |
| 29 | +Parameter names are the full paths from the top-level group to the specific parameter. |
| 30 | +For example: |
| 31 | + |
| 32 | +* ``http.host`` is the ``host`` parameter that is defined directly in the ``http`` group. |
| 33 | +* ``http.tls.enabled`` is the ``enabled`` parameter that is defined in the ``tls`` |
| 34 | + nested group within ``http``. |
| 35 | + |
| 36 | +The following fragment |
| 37 | + |
| 38 | +.. _tcm_configuration_ways: |
| 39 | + |
| 40 | +Ways to pass |tcm| configuration parameters |
| 41 | +------------------------------------------- |
| 42 | + |
| 43 | +There are three ways to pass |tcm| configuration parameters: a YAML file, |
| 44 | +environment variables, and the command-line options of the |tcm| executable. |
| 45 | + |
| 46 | +.. _tcm_configuration_ways_yaml: |
| 47 | + |
| 48 | +YAML configuration file |
| 49 | +~~~~~~~~~~~~~~~~~~~~~~~ |
| 50 | + |
| 51 | +|tcm| configuration can be stored in a YAML file. Its content must reflect the |
| 52 | +configuration parameters hierarchy. |
| 53 | + |
| 54 | +The example below shows a shows a fragment of a |tcm| configuration file: |
| 55 | + |
| 56 | +.. code-block::yaml |
| 57 | +
|
| 58 | + cluster: |
| 59 | + on-air-limit: 4096 |
| 60 | + connection-rate-limit: 512 |
| 61 | + tarantool-timeout: 10s |
| 62 | + tarantool-ping-timeout: 5s |
| 63 | + http: |
| 64 | + basic-auth: |
| 65 | + enabled: false |
| 66 | + network: tcp |
| 67 | + host: 127.0.0.1 |
| 68 | + port: 8080 |
| 69 | + request-size: 1572864 |
| 70 | + websocket: |
| 71 | + read-buffer-size: 16384 |
| 72 | + write-buffer-size: 16384 |
| 73 | + keepalive-ping-interval: 20s |
| 74 | + handshake-timeout: 10s |
| 75 | + init-timeout: 15s |
| 76 | +
|
| 77 | +.. code-block::yaml |
| 78 | +
|
| 79 | +The location of a YAML configuration file must be passed during the |tcm| startup in the ``-c`` |
| 80 | +command-line option: |
| 81 | + |
| 82 | +.. code-block::console |
| 83 | +
|
| 84 | + ./tcm -c=config.yml |
| 85 | +
|
| 86 | +.. _tcm_configuration_ways_env: |
| 87 | + |
| 88 | +Environment variables |
| 89 | +~~~~~~~~~~~~~~~~~~~~~ |
| 90 | + |
| 91 | +|tcm| can take values of its configuration parameters from environment variables. |
| 92 | +The variable names start with ``TCM_``. Then goes the full path to the parameter, |
| 93 | +converted to upper case. All delimiters are replaced with underscores (``_``). |
| 94 | +For example, ``TCM_HTTP_HOST`` is a variable for the ``http.host`` parameter, |
| 95 | +and ``TCM_HTTP_WEBSESSION_COOKIE_NAME`` is for ``http.websession-cookie.name``. |
| 96 | + |
| 97 | +The example below shows how to start |tcm| passing configuration parameters in |
| 98 | +environment variables: |
| 99 | + |
| 100 | + .. code-block::console |
| 101 | +
|
| 102 | + export TCM_HTTP_HOST="0.0.0.0" |
| 103 | + export TCM_HTTP_POST="8888" |
| 104 | + ./tcm |
| 105 | +
|
| 106 | +.. _tcm_configuration_ways_cli: |
| 107 | + |
| 108 | +Command-line arguments |
| 109 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 110 | + |
| 111 | +|tcm| executable has ``--`` command-line options for each configuration parameter. |
| 112 | +Their names reflect the full path to the parameter, with all delimiters replaced by |
| 113 | +hyphens (``-``). For example, ``--http-host`` is an option for ``http.host``, |
| 114 | +and ``--http-websession-cookie-name`` is for ``http.websession-cookie.name``. |
| 115 | + |
| 116 | +The example below shows how to start |tcm| passing configuration parameters in |
| 117 | +command-line options: |
| 118 | + |
| 119 | +.. code-block::console |
| 120 | +
|
| 121 | + ./tcm --storage.etcd.embed.enabled --addon.enabled --http.host=0.0.0.0 --http.port=8888 |
| 122 | +
|
| 123 | +
|
| 124 | +.. _tcm_configuration_precedence: |
| 125 | + |
| 126 | +Configuration precedence |
| 127 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 128 | + |
| 129 | +|tcm| configuration options are applied from multiple sources with the following precedence, |
| 130 | +from highest to lowest: |
| 131 | + |
| 132 | +- ``tcm`` executable arguments. |
| 133 | +- `TCM_*` environment variables. |
| 134 | +- Configuration from a YAML file. |
| 135 | + |
| 136 | +If the same option is defined in two or more locations, the option with the highest precedence is applied. |
| 137 | + |
| 138 | +You can combine different ways of |tcm| configuration for efficient management of |
| 139 | +multiple |tcm| installations: |
| 140 | + |
| 141 | +- A single YAML file for all installations can contain the common configuration parts. |
| 142 | + For example, the security parameters that fulfill your organization's requirements. |
| 143 | +- Environment variables that set specific parameters for each server, such as |
| 144 | + ?? any good example?? |
| 145 | +- Command-line options for parameters that must be unique for different |tcm| instances |
| 146 | + running on a single server. For example, ``http.port``. |
| 147 | + |
| 148 | +Configuration parameter types |
| 149 | +----------------------------- |
| 150 | + |
| 151 | +|tcm| configuration parameters have the `Go <https://go.dev/>`__ language |
| 152 | +types. Note that this is different from the :ref`Tarantool configuration parameters <configuration_reference>`, |
| 153 | +which have Lua types. |
| 154 | + |
| 155 | +Most options have the Go's basic types: `bool`, `string`, `int`, and other integer |
| 156 | +numeric types. |
| 157 | + |
| 158 | +Parameters that can take multiple values are arrays. In YAML, they are passed as |
| 159 | +YAML arrays (each item on a new line, starting with a dash). In environment variables |
| 160 | +and command line options, the items of such arrays are passed in a semicolon-separated string. |
| 161 | + |
| 162 | +Parameters that set timeouts, TTLs, and other duration values, have the Go's `time.Duration <https://pkg.go.dev/time#Duration>`__ |
| 163 | +type. This enables passing the values in the time-formatted strings such as ``4h30m25s``. |
| 164 | + |
| 165 | + |
| 166 | +? Configuration example or template for readers? |
| 167 | +------------------------------------------------ |
0 commit comments