You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
msgid"For each Tarantool instance, you need two files:"
20
+
msgid"Application environment"
25
21
msgstr""
26
22
27
23
#:../../doc/book/admin/instance_config.rst:8
28
-
msgid"[Optional] An :ref:`application file <app_server-launching_app>` with instance-specific logic. Put this file into the ``/usr/share/tarantool/`` directory."
24
+
msgid"This section provides a high-level overview on how to prepare a Tarantool application for deployment and how the application's environment and layout might look. This information is helpful for understanding how to administer Tarantool instances using :ref:`tt CLI <tt-cli>` in both development and production environments."
29
25
msgstr""
30
26
31
27
#:../../doc/book/admin/instance_config.rst:12
32
-
msgid"For example, ``/usr/share/tarantool/my_app.lua`` (here we implement it as a :ref:`Lua module <app_server-modules>` that bootstraps the database and exports ``start()`` function for API calls):"
28
+
msgid"The main steps of creating and preparing the application for deployment are:"
msgid"An :ref:`instance file <admin-instance_file>` with instance-specific initialization logic and parameters. Put this file, or a symlink to it, into the **instance directory** (see ``instances_enabled`` parameter in :ref:`tt configuration file <tt-config_file>`)."
39
+
#:../../doc/book/admin/instance_config.rst:18
40
+
msgid":ref:`admin-instance_config-package-app`."
49
41
msgstr""
50
42
51
-
#:../../doc/book/admin/instance_config.rst:33
52
-
msgid"For example, ``/etc/tarantool/instances.enabled/my_app.lua`` (here we load ``my_app.lua`` module and make a call to ``start()`` function from that module):"
43
+
#:../../doc/book/admin/instance_config.rst:20
44
+
msgid"In this section, a `sharded_cluster <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster>`_ application is used as an example. This cluster includes 5 instances: one router and 4 storages, which constitute two replica sets."
53
45
msgstr""
54
46
55
-
#:../../doc/book/admin/instance_config.rst:37
56
-
msgid"#!/usr/bin/env tarantool\n"
57
-
"\n"
58
-
"box.cfg {\n"
59
-
" listen = 3301;\n"
60
-
"}\n"
61
-
"\n"
62
-
"-- load my_app module and call start() function\n"
63
-
"-- with some app options controlled by sysadmins\n"
64
-
"local m = require('my_app').start({...})"
47
+
#:../../doc/book/admin/instance_config.rst:None
48
+
#:../../doc/book/admin/instance_config.rst:0
49
+
#:../../doc/book/admin/instance_config.rst:0
50
+
msgid"Cluster topology"
65
51
msgstr""
66
52
67
-
#:../../doc/book/admin/instance_config.rst:52
68
-
msgid"Instance file"
53
+
#:../../doc/book/admin/instance_config.rst:34
54
+
msgid"Initializing a local environment"
69
55
msgstr""
70
56
71
-
#:../../doc/book/admin/instance_config.rst:54
72
-
msgid"After this short introduction, you may wonder what an instance file is, what it is for, and how ``tt`` uses it. After all, Tarantool is an application server, so why not start the application stored in ``/usr/share/tarantool`` directly?"
57
+
#:../../doc/book/admin/instance_config.rst:36
58
+
msgid"Before creating an application, you need to set up a local environment for``tt``:"
73
59
msgstr""
74
60
75
-
#:../../doc/book/admin/instance_config.rst:59
76
-
msgid"A typical Tarantool application is not a script, but a daemon running in background mode and processing requests, usually sent to it over a TCP/IP socket. This daemon needs to be started automatically when the operating system starts, and managed with the operating system standard tools for service management -- such as ``systemd`` or ``init.d``. To serve this very purpose, we created **instance files**."
61
+
#:../../doc/book/admin/instance_config.rst:38
62
+
msgid"Create a home directory for the environment."
63
+
msgstr""
64
+
65
+
#:../../doc/book/admin/instance_config.rst:40
66
+
msgid"Run ``tt init`` in this directory:"
67
+
msgstr""
68
+
69
+
#:../../doc/book/admin/instance_config.rst:42
70
+
msgid"~/myapp$ tt init\n"
71
+
" • Environment config is written to 'tt.yaml'"
72
+
msgstr""
73
+
74
+
#:../../doc/book/admin/instance_config.rst:47
75
+
msgid"This command creates a default ``tt`` configuration file ``tt.yaml`` for a local environment and the directories for applications, control sockets, logs, and other artifacts:"
76
+
msgstr""
77
+
78
+
#:../../doc/book/admin/instance_config.rst:51
79
+
msgid"~/myapp$ ls\n"
80
+
"bin distfiles include instances.enabled modules templates tt.yaml"
81
+
msgstr""
82
+
83
+
#:../../doc/book/admin/instance_config.rst:56
84
+
msgid"Find detailed information about the ``tt`` configuration parameters and launch modes on the :ref:`tt configuration page <tt-config>`."
77
85
msgstr""
78
86
79
87
#:../../doc/book/admin/instance_config.rst:66
80
-
msgid"You can have more than one instance file. For example, a single application in ``/usr/share/tarantool`` can run in multiple instances, each of them having its own instance file. Or you can have multiple applications in ``/usr/share/tarantool`` -- again, each of them having its own instance file."
88
+
msgid"Creating and developing an application"
81
89
msgstr""
82
90
83
-
#:../../doc/book/admin/instance_config.rst:71
84
-
msgid"An instance file is typically created by a system administrator. An application file is often provided by a developer, in a Lua rock or an rpm/deb package."
91
+
#:../../doc/book/admin/instance_config.rst:68
92
+
msgid"You can create an application in two ways:"
85
93
msgstr""
86
94
87
-
#:../../doc/book/admin/instance_config.rst:74
88
-
msgid"An instance file is designed to not differ in any way from a Lua application. It must, however, configure the database, i.e. contain a call to :doc:`box.cfg{} </reference/reference_lua/box_cfg>` somewhere in it, because it’s the only way to turn a Tarantool script into a background process, and ``tt`` is a tool to manage background processes. Other than that, an instance file may contain arbitrary Lua code, and, in theory, even include the entire application business logic in it. We, however, do not recommend this, since it clutters the instance file and leads to unnecessary copy-paste when you need to run multiple instances of an application."
95
+
#:../../doc/book/admin/instance_config.rst:70
96
+
msgid"Manually by preparing its layout in a directory inside ``instances_enabled``. The directory name is used as the application identifier."
89
97
msgstr""
90
98
91
-
#:../../doc/book/admin/instance_config.rst:87
92
-
msgid"Preloading Lua scripts and modules"
99
+
#:../../doc/book/admin/instance_config.rst:73
100
+
msgid"From a template by using the :ref:`tt create <tt-create>` command."
93
101
msgstr""
94
102
95
-
#:../../doc/book/admin/instance_config.rst:89
96
-
msgid"Tarantool supports loading and running chunks of Lua code before the loading instance file. To load or run Lua code immediately upon Tarantool startup, specify the ``TT_PRELOAD`` environment variable. Its value can be either a path to a Lua script or a Lua module name:"
103
+
#:../../doc/book/admin/instance_config.rst:75
104
+
msgid"In this example, the application's layout is prepared manually and looks as follows."
97
105
msgstr""
98
106
99
-
#:../../doc/book/admin/instance_config.rst:93
100
-
msgid"To run the Lua script ``script.lua`` from the ``preload/path/`` directory inside the working directory in Tarantool before ``main.lua``, set ``TT_PRELOAD`` as follows:"
msgid"The ``sharded_cluster`` directory contains the following files:"
127
+
msgstr""
128
+
129
+
#:../../doc/book/admin/instance_config.rst:98
130
+
msgid"``config.yaml``: contains the :ref:`configuration <configuration>` of the cluster. This file might include the entire cluster topology or provide connection settings to a centralized configuration storage."
131
+
msgstr""
132
+
133
+
#:../../doc/book/admin/instance_config.rst:99
134
+
msgid"``instances.yml``: specifies instances to run in the current environment. For example, on the developer’s machine, this file might include all the instances defined in the cluster configuration. In the production environment, this file includes :ref:`instances to run on the specific machine <admin-instances_to_run>`."
105
135
msgstr""
106
136
107
137
#:../../doc/book/admin/instance_config.rst:100
108
-
msgid"Tarantool runs the ``script.lua``code, waits for it to complete, and then starts running ``main.lua``."
138
+
msgid"``router.lua``: includes code specific for a :ref:`router <vshard-architecture-router>`."
109
139
msgstr""
110
140
111
-
#:../../doc/book/admin/instance_config.rst:103
112
-
msgid"To load the ``preload.module`` into the Tarantool Lua interpreter executing ``main.lua``, set ``TT_PRELOAD`` as follows:"
141
+
#:../../doc/book/admin/instance_config.rst:101
142
+
msgid"``sharded_cluster-scm-1.rockspec``: specifies the required external dependencies (for example, ``vshard``)."
msgid"``storage.lua``: includes code specific for :ref:`storages <vshard-architecture-storage>`."
117
147
msgstr""
118
148
119
-
#:../../doc/book/admin/instance_config.rst:110
120
-
msgid"Tarantool loads the ``preload.module`` code into the interpreter and starts running ``main.lua`` as if its first statement was ``require('preload.module')``."
149
+
#:../../doc/book/admin/instance_config.rst:104
150
+
msgid"You can find the full example here: `sharded_cluster <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster>`_."
121
151
msgstr""
122
152
123
-
#:../../doc/book/admin/instance_config.rst:115
124
-
msgid"``TT_PRELOAD`` values that end with ``.lua`` are considered scripts, so avoid module names with this ending."
153
+
#:../../doc/book/admin/instance_config.rst:114
154
+
msgid"Packaging the application"
125
155
msgstr""
126
156
127
-
#:../../doc/book/admin/instance_config.rst:118
128
-
msgid"To load several scripts or modules, pass them in a single quoted string, separated by semicolons:"
157
+
#:../../doc/book/admin/instance_config.rst:116
158
+
msgid"To package the ready application, use the :ref:`tt pack <tt-pack>` command. This command can create an installable DEB/RPM package or generate ``.tgz`` archive."
msgid"The structure below reflects the content of the packed ``.tgz`` archive for the `sharded_cluster <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster>`_ application:"
133
163
msgstr""
134
164
135
-
#:../../doc/book/admin/instance_config.rst:125
136
-
msgid"In the preload script, the three dots (``...``) value contains the module name if you're preloading a module or the path to the script if you're running a script."
165
+
#:../../doc/book/admin/instance_config.rst:121
166
+
msgid"~/myapp$ tree -a\n"
167
+
".\n"
168
+
"├── bin\n"
169
+
"│ ├── tarantool\n"
170
+
"│ └── tt\n"
171
+
"├── include\n"
172
+
"├── instances.enabled\n"
173
+
"│ └── sharded_cluster -> ../sharded_cluster\n"
174
+
"├── modules\n"
175
+
"├── sharded_cluster\n"
176
+
"│ ├── .rocks\n"
177
+
"│ │ └── share\n"
178
+
"│ │ └── ...\n"
179
+
"│ ├── config.yaml\n"
180
+
"│ ├── instances.yaml\n"
181
+
"│ ├── router.lua\n"
182
+
"│ ├── sharded_cluster-scm-1.rockspec\n"
183
+
"│ └── storage.lua\n"
184
+
"└── tt.yaml"
137
185
msgstr""
138
186
139
-
#:../../doc/book/admin/instance_config.rst:128
140
-
msgid"The :ref:`arg <index-init_label>` value from the main script is visible in the preload script or module."
187
+
#:../../doc/book/admin/instance_config.rst:144
188
+
msgid"The application's layout looks similar to the one defined when :ref:`developing the application <admin-instance_config-develop-app>` with some differences:"
141
189
msgstr""
142
190
143
-
#:../../doc/book/admin/instance_config.rst:131
144
-
msgid"For example, when preloading this script:"
191
+
#:../../doc/book/admin/instance_config.rst:146
192
+
msgid"``bin``: contains the ``tarantool`` and ``tt`` binaries packed with the application bundle."
145
193
msgstr""
146
194
147
-
#:../../doc/book/admin/instance_config.rst:133
148
-
msgid"-- preload.lua --\n"
149
-
"print(\"Preloading:\")\n"
150
-
"print(\"... arg is:\", ...)\n"
151
-
"print(\"Passed args:\", arg[1], arg[2])"
195
+
#:../../doc/book/admin/instance_config.rst:148
196
+
msgid"``instances.enabled``: contains a symlink to the packed ``sharded_cluster`` application."
152
197
msgstr""
153
198
154
-
#:../../doc/book/admin/instance_config.rst:140
155
-
msgid"You get the following output:"
199
+
#:../../doc/book/admin/instance_config.rst:150
200
+
msgid"``sharded_cluster``: a packed application. In addition to files created during the application development, includes the ``.rocks`` directory containing application dependencies (for example, ``vshard``)."
"... main/103/main.lua I> wal/engine cleanup is paused\n"
167
-
"< ... >"
203
+
#:../../doc/book/admin/instance_config.rst:152
204
+
msgid"``tt.yaml``: a ``tt`` configuration file."
168
205
msgstr""
169
206
170
-
#:../../doc/book/admin/instance_config.rst:154
171
-
msgid"If an error happens during the execution of the preload script or module, Tarantool reports the problem and exits."
207
+
#:../../doc/book/admin/instance_config.rst:159
208
+
msgid"Instances to run"
172
209
msgstr""
173
210
174
-
#:../../doc/book/admin/instance_config.rst:160
175
-
msgid"tt configuration file"
211
+
#:../../doc/book/admin/instance_config.rst:161
212
+
msgid"One more difference for a deployed application is the content of the ``instances.yaml`` file that specifies instances to run in the current environment."
176
213
msgstr""
177
214
178
-
#:../../doc/book/admin/instance_config.rst:162
179
-
msgid"While instance files contain instance configuration, the :ref:`tt <tt-cli>` configuration file contains the configuration that ``tt`` uses to set up the application environment. This includes the path to instance files, various working directories, and other parameters that connect the application to the system."
215
+
#:../../doc/book/admin/instance_config.rst:163
216
+
msgid"On the developer's machine, this file might include all the instances defined in the cluster configuration."
180
217
msgstr""
181
218
182
-
#:../../doc/book/admin/instance_config.rst:167
183
-
msgid"To create a default ``tt`` configuration, run ``tt init``. This creates a ``tt.yaml`` configuration file. Its location depends on the :ref:`tt launch mode <tt-config_modes>` (system or local)."
219
+
#:../../doc/book/admin/instance_config.rst:170
220
+
msgid"``instances.yaml``:"
184
221
msgstr""
185
222
186
-
#:../../doc/book/admin/instance_config.rst:171
187
-
msgid"Some ``tt`` configuration parameters are similar to those used by :doc:`box.cfg{} </reference/reference_lua/box_cfg>`, for example, ``memxt_dir`` or ``wal_dir``. Other parameters define the ``tt`` environment, for example, paths to installation files used by ``tt`` or to connected :ref:`external modules <tt-external_modules>`."
223
+
#:../../doc/book/admin/instance_config.rst:172
224
+
msgid"storage-a-001:\n"
225
+
"storage-a-002:\n"
226
+
"storage-b-001:\n"
227
+
"storage-b-002:\n"
228
+
"router-a-001:"
188
229
msgstr""
189
230
190
231
#:../../doc/book/admin/instance_config.rst:176
191
-
msgid"Find the detailed information about the ``tt`` configuration parameters and launch modes on the :ref:`tt configuration page <tt-config>`."
232
+
msgid"In the production environment, this file includes instances to run on the specific machine."
233
+
msgstr""
234
+
235
+
#:../../doc/book/admin/instance_config.rst:183
236
+
msgid"``instances.yaml`` (Server-001):"
237
+
msgstr""
238
+
239
+
#:../../doc/book/admin/instance_config.rst:185
240
+
msgid"router-a-001:"
241
+
msgstr""
242
+
243
+
#:../../doc/book/admin/instance_config.rst:189
244
+
msgid"``instances.yaml`` (Server-002):"
245
+
msgstr""
246
+
247
+
#:../../doc/book/admin/instance_config.rst:191
248
+
msgid"storage-a-001:\n"
249
+
"storage-b-001:"
250
+
msgstr""
251
+
252
+
#:../../doc/book/admin/instance_config.rst:196
253
+
msgid"``instances.yaml`` (Server-003):"
254
+
msgstr""
255
+
256
+
#:../../doc/book/admin/instance_config.rst:198
257
+
msgid"storage-a-002:\n"
258
+
"storage-b-002:"
259
+
msgstr""
260
+
261
+
#:../../doc/book/admin/instance_config.rst:204
262
+
msgid"The :ref:`Starting and stopping instances <admin-start_stop_instance>` section describes how to start and stop Tarantool instances."
0 commit comments