Skip to content

Commit

Permalink
Add TT_PRELOAD doc
Browse files Browse the repository at this point in the history
  • Loading branch information
p7nov committed Aug 15, 2023
1 parent 2535467 commit 126e3ae
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions doc/book/admin/instance_config.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.. _admin-instance_config:

================================================================================
Instance configuration
================================================================================
======================

For each Tarantool instance, you need two files:

Expand Down Expand Up @@ -50,9 +49,8 @@ For each Tarantool instance, you need two files:
.. _admin-instance_file:

--------------------------------------------------------------------------------
Instance file
--------------------------------------------------------------------------------
-------------

After this short introduction, you may wonder what an instance file is, what it
is for, and how ``tarantoolctl`` uses it. After all, Tarantool is an application
Expand Down Expand Up @@ -84,11 +82,45 @@ 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.

.. _admin-tt-preload:

Preloading Lua scripts and modules
----------------------------------

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.

* Run the Lua script ``script.lua`` from the ``preload/path/`` directory inside
the working directory in Tarantool before executing ``main.lua``:

.. code-block:: bash
TT_PRELOAD=/preload/path/script.lua tarantool main.lua
* Load the ``preload.module`` into the Tarantool Lua interpreter
executing ``main.lua``:

.. code-block:: bash
TT_PRELOAD=preload.module tarantool main.lua
.. warning::

``TT_PRELOAD`` values that end with ``.lua`` are considered scripts,
so avoid modules names with this ending.

To load several scripts or modules, pass them in a single quoted string separated
by semicolons:

.. code-block:: bash
TT_PRELOAD="/preload/path/script.lua;preload.module" tarantool main.lua
.. _admin-tarantoolctl_config_file:

--------------------------------------------------------------------------------
tarantoolctl configuration file
--------------------------------------------------------------------------------
-------------------------------

While instance files contain instance configuration, the ``tarantoolctl``
configuration file contains the configuration that ``tarantoolctl`` uses to
Expand Down

0 comments on commit 126e3ae

Please sign in to comment.