Run with no docker

Installation

For proper installation you need to clone project from git.

There are LIM service sub-folders in the root of the project: /indexer, /manager, /matcher. To run a specific service, you need to go to the service sub-folder and follow the instructions.

Surroundings

The service can be installed on Windows 10 and AlmaLinux (not tested on other system versions).

Required predefined dependencies:

  • Python v. 3.12 is required

Dependency installation

After surroundings installation the application dependencies should be installed using poetry.

pip install poetry
poetry install

Configuration

After dependencies installation configuration file should be set. File is placed in “./config/config.conf”.

Initialization

Run the following command to generate server documentation & initialize version:

(cd .. && make docs)

First launch and testing

If all previous actions are executed successfully, server is ready to work. To start server please execute run.py script. You can add optional arguments: server port and number of workers, servicing the server. Also you can change custom log file suffix.

Example of service run command executing from root directory:

python run.py --workers=2 --port=5191 --log_suffix=awesome --config=./config/config.conf

Worker count, port and path to configuration file are command line arguments. Default ports for Luna Index Module services are the following:

service

default port

lim-indexer

5180

lim-manager

5190

lim-matcher

5200

Also it possible to run service with config from Luna Configurator. Example:

./run.py --luna-config http://127.0.0.1:5071/1

See command line help for details:

python ./run.py --help

After server is started, testing is recommended. To perform testing execute command

pytest -n 2 tests

All tests should perform successfully.

Deploy

There are several options for sanic server deployment:

  • Standalone server

  • Running a pool of backend servers behind of nginx, HAProxy or other reverse proxy server. Several instances of sanic can be managed with systemd (Nginx+systemd)

Running sanic servers behind nginx makes several advantages:

  • Second, running several sanic instances behind nginx allows to utilize all CPU cores.

  • Third, nginx serves static files much faster than built-in sanic static file support.

Template configuration files for nginx are presented below. For more information, you can visit sanic.readthedocs.io.

Configuration files for nginx

upstream app {
    server 127.0.0.1:5181 fail_timeout=0;
    server 127.0.0.1:5182 fail_timeout=0;
}

server {
    listen 5180;
    client_max_body_size 4G;
    server_name lim_indexer;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://app;
    }
}
upstream app {
    server 127.0.0.1:5191 fail_timeout=0;
    server 127.0.0.1:5192 fail_timeout=0;
}

server {
    listen 5190;
    client_max_body_size 4G;
    server_name lim_manager;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://app;
    }
}
upstream app {
    server 127.0.0.1:5201 fail_timeout=0;
    server 127.0.0.1:5202 fail_timeout=0;
}

server {
    listen 5200;
    client_max_body_size 4G;
    server_name lim_matcher;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://app;
    }
}

Configuration files for systemd

Configs should be located in directory /etc/systemd/system/

[Unit]
Description=Luna Indexer on port %i
After=network.target

[Service]
Restart=always
RestartSec=5
SyslogIdentifier=lim-indexer-%i
User=luna
Group=luna
WorkingDirectory=/var/lib/luna/current/lim-indexer/lim_indexer

# Run from luna-configurator
ExecStart=/var/lib/luna/current/lim-indexer/venv/bin/python ./run.py --port=%i --config-reload=0 --luna-config=http://127.0.0.1:5070/1 --log_suffix=%i
# Run from config file
# ExecStart=/var/lib/luna/current/lim-indexer/venv/bin/python ./run.py --port=%i --config-reload=0 --config=./configs/config.conf --log_suffix=%i

[Install]
WantedBy=multi-user.target
[Unit]
Description=Luna Index Manager on port %i
After=network.target

[Service]
Restart=always
RestartSec=5
SyslogIdentifier=lim-manager-%i
User=luna
Group=luna
WorkingDirectory=/var/lib/luna/current/lim-manager/lim_manager

# Run from luna-configurator
ExecStart=/var/lib/luna/current/lim-manager/venv/bin/python ./run.py --port=%i --config-reload=0 --luna-config=http://127.0.0.1:5070/1 --log_suffix=%i
# Run from config file
# ExecStart=/var/lib/luna/current/lim-manager/venv/bin/python ./run.py --port=%i --config-reload=0 --config=./configs/config.conf --log_suffix=%i

[Install]
WantedBy=multi-user.target
[Unit]
Description=Luna Indexed Matcher on port %i
After=network.target

[Service]
Restart=always
RestartSec=5
SyslogIdentifier=lim-matcher-%i
User=luna
Group=luna
WorkingDirectory=/var/lib/luna/current/lim/matcher/lim_matcher

# Run from luna-configurator
ExecStart=/var/lib/luna/current/lim/matcher/venv/bin/python ./run.py --port=%i --config-reload=0 --luna-config=http://127.0.0.1:5070/1 --log_suffix=%i
# Run from config file
# ExecStart=/var/lib/luna/current/lim/matcher/venv/bin/python ./run.py --port=%i --config-reload=0 --config=./configs/config.conf --log_suffix=%i

[Install]
WantedBy=multi-user.target

Start instances:

sudo systemctl start lim-indexer.service
sudo systemctl start lim-manager.service
sudo systemctl start lim-matcher.service