Skip to content

Add tt run and tt instances #3395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/reference/tooling/tt_cli/check.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Checking an application file
Details
-------

``tt`` searches for ``APP_FILE`` inside the ``instances_available`` directory
``tt`` searches for ``APP_FILE`` inside the ``instances_enabled`` directory
specified in the :ref:`tt configuration file <tt-config_file_app>`. ``APP_FILE`` can be:

* the name of an application file without the ``.lua`` extension.
Expand All @@ -20,14 +20,14 @@ specified in the :ref:`tt configuration file <tt-config_file_app>`. ``APP_FILE``
Examples
--------

* Check the syntax of the ``app.lua`` file from the ``instances_available`` directory:
* Check the syntax of the ``app.lua`` file from the ``instances_enabled`` directory:

.. code-block:: bash

tt check app


* Check the syntax of the ``init.lua`` file from the ``instance1/`` directory inside ``instances_available``:
* Check the syntax of the ``init.lua`` file from the ``instance1/`` directory inside ``instances_enabled``:

.. code-block:: bash

Expand Down
6 changes: 6 additions & 0 deletions doc/reference/tooling/tt_cli/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ help for the given command.
- Create a new ``tt`` environment in the current directory
* - :doc:`install <install>`
- Install Tarantool or ``tt``
* - :doc:`instances <instances>`
- List enabled applications
* - :doc:`logrotate <logrotate>`
- Rotate instance logs
* - :doc:`play <play>`
Expand All @@ -42,6 +44,8 @@ help for the given command.
- Restart a Tarantool instance
* - :doc:`rocks <rocks>`
- Use the LuaRocks package manager
* - :doc:`run <run>`
- Run Lua code in a Tarantool instance
* - :doc:`search <search>`
- Search available Tarantool and ``tt`` versions
* - :doc:`start <start>`
Expand All @@ -68,10 +72,12 @@ help for the given command.
create <create>
help <help>
install <install>
instances <instances>
logrotate <logrotate>
play <play>
restart <restart>
rocks <rocks>
run <run>
search <search>
start <start>
status <status>
Expand Down
4 changes: 2 additions & 2 deletions doc/reference/tooling/tt_cli/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The ``tt`` configuration file is a YAML file with the following content:
modules:
directory: path/to/modules/dir
app:
instances_available: path/to/available/applications
instances_enabled: path/to/applications
run_dir: path/to/run_dir
log_dir: path/to/log_dir
bin_dir: path/to/bin_dir
Expand Down Expand Up @@ -54,7 +54,7 @@ modules section
app section
~~~~~~~~~~~

* ``instances_available`` -- the directory where :ref:`instances <admin-instance_file>`
* ``instances_enabled`` -- the directory where :ref:`instances <admin-instance_file>`
are stored.
* ``run_dir``-- the directory for instance runtime artifacts, such as console
sockets or PID files. Default: ``var/run``.
Expand Down
26 changes: 26 additions & 0 deletions doc/reference/tooling/tt_cli/instances.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _tt-instances:

Listing enabled applications
============================

.. code-block:: bash

tt instances

``tt instances`` shows the list of enabled applications.

.. note::

*Enabled* applications are applications that are stored inside the ``instances_enabled``
directory specified in the :ref:`tt configuration file <tt-config_file_app>`.
They can be either running or not. To check if an application is running,
use :doc:`tt status <status>`.

Example
--------

* Show the list of enabled applications:

.. code-block:: bash

tt instances
71 changes: 71 additions & 0 deletions doc/reference/tooling/tt_cli/run.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. _tt-run:

Running code in a Tarantool instance
====================================

.. code-block:: bash

tt run [SCRIPT|-e EXPR] [flags]

``tt run`` executes Lua code in a Tarantool instance.

Flags
-----

.. container:: table

.. list-table::
:widths: 30 70
:header-rows: 0

* - ``-e EXPR``

``--evaluate EXPR``
- Execute the specified expression in a Tarantool instance
* - ``-l LIB_NAME``

``--library LIB_NAME``
- Require the specified library
* - ``-i``

``--interactive``
- Enter the interactive mode after the script execution
* - ``-v``

``--version``
- Print the Tarantool version that is used for script execution

Details
-------

``tt run`` executes arbitrary Lua code in a Tarantool instance. The code can be
provided either in a Lua file, or in a string passed after the ``-e``/``--evaluate``
flag. When called without arguments or flags, ``tt run`` opens the Tarantool console.

If libraries are required for execution, pass their names after the ``-l``/``--library``
flag.

By default, a Tarantool instance started by ``tt run`` shuts down after code
execution completes. To leave this instance running and continue working in its
console, add the ``-i``/``--interactive`` flag.

Examples
--------

* Execute the ``app.lua`` file in a Tarantool instance:

.. code-block:: bash

tt run app.lua

* Execute an expression in a Tarantool instance:

.. code-block:: bash

tt run -e "print('hi there')"

* Execute the ``app.lua`` file in a Tarantool instance and leave it running:

.. code-block:: bash

tt run app.lua -i
9 changes: 5 additions & 4 deletions doc/reference/tooling/tt_cli/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Starting a Tarantool instance
Details
-------

The application files must be stored inside the ``instances_available``
The application files must be stored inside the ``instances_enabled``
directory specified in the :ref:`tt configuration file <tt-config_file_app>`.
The ``APPLICATION`` value can be:

Expand All @@ -29,7 +29,7 @@ Examples
Single instance
~~~~~~~~~~~~~~~

* Start an instance with the ``app.lua`` application from the ``instances_available``
* Start an instance with the ``app.lua`` application from the ``instances_enabled``
directory:

.. code-block:: bash
Expand All @@ -41,13 +41,14 @@ Multiple instances
~~~~~~~~~~~~~~~~~~

* Start all instances of the application stored in the ``app/`` directory inside
``instances_available`` in accordance with the :ref:`instances configuration <tt-instances>`:
``instances_enabled`` in accordance with the :ref:`instances configuration <tt-instances>`:

.. code-block:: bash

tt start app

* Start only the ``master`` instance of the application stored in the ``app/`` directory inside ``instances_available``:
* Start only the ``master`` instance of the application stored in the ``app/`` directory inside ``instances_enabled``:

.. code-block:: bash

tt start app:master