Installation

This section describes LUNA Backport 3 installation and configuration.

Service requirements

  • The service can be installed on CentOS 7 (not tested on other system versions)

  • Python 3.12 is required

Install Python

The recommended Python version is 3.12

See the information about Python installation on the official website. https://www.python.org/downloads/

Install database

You can use PostgreSQL or Oracle as a database.

  • The recommended version of PostgreSQL is 12

  • The recommended version of Oracle is 11.2

Read about the databases installation on their official websites:

https://www.postgresql.org/download/linux/redhat/

https://docs.oracle.com/en/database/oracle/oracle-database/index.html

Create database

Run the PostgreSQL management tool (if you are using PostgreSQL).

note:

Make sure that you are not in the “/root” directory before launching the tool.

psql -U postgres;

Create the user for the database (if it is not created):

CREATE ROLE luna;

ALTER USER luna WITH PASSWORD 'luna';

Create the database for Backport 3.

CREATE DATABASE luna_backport3;

GRANT ALL PRIVILEGES ON DATABASE luna_backport3 TO luna;

ALTER ROLE luna WITH LOGIN;

Install Python libraries

note:

The virtual environment is strongly recommended for the installation of the service.

  • Go to the project source directory:

cd ./luna-backport3/
  • Create a virtual environment:

python -m venv venv
  • If you are using PostgreSQL, add the path to it to the environment variable:

PATH=/usr/pgsql-12/bin/:$PATH
  • Activate the virtual environment by the command:

source ./venv/bin/activate
  • Install dependencies by the command:

pip install -r requirements.txt
  • Launch db_create.py script for tables and primal data creation. This script also applies all the available migrations for the database.There are two ways to receive the configurations: using the Configurator service or from the “config.conf” file.

In this example the configurations are received from the “config.conf” file.

python ./base_scripts/db_create.py

In this example the configurations are received using the Configurator service.

python ./base_scripts/db_create.py --luna-config http://127.0.0.1:5070/1

One can call the following command for more information about the available arguments:

python base_scripts/db_create.py --help

If script was executed without errors, all schemas were created successfully. * You must create a bucket for the Backport 3 service.

The script receives the name of the bucket and the Image Store service address from the config.

The name of the bucket is specified in the “BUCKET” parameter of the Backport 3 config.

Note that this script doesn’t check if bucket already exists or not.

The Image Store service must be launched before the bucket creation.

  • Initiate Image Store storage bucket creation

python ./base_scripts/lis_bucket_create.py

You can use the request using CURL instead of the “lis_bucket_create.py” script for the bucket creation.

curl -X POST http://127.0.0.1:5020/1/buckets?bucket=portraits
  • Use the following command for the virtual environment deactivation:

deactivate

Migrations

You should perform migrations if you update from LUNA PLATFORM 3 to LUNA PLATFORM 5 Backport 3. Read about them here “Migration”.

Check configs

Check and change the service settings in the configuration file ./luna-backport3/luna_backport3/configs/config.conf (if necessary):


[LUNA_CONFIGURATOR]
#: load configs from LUNA Configurator
USE_CONFIGURATOR = 0
#: LUNA Configurator protocol, IP address, and port
LUNA_CONFIGURATOR_ORIGIN = http://127.0.0.1:5070
#: API version of the LUNA Configurator
LUNA_CONFIGURATOR_API  = 1


[LUNA_BACKPORT3_LOGGER]

#: folder, where logs are saved
FOLDER_WITH_LOGS = ./
#: level of debug print, by priority: "ERROR", "WARNING", "INFO", "DEBUG"
LOG_LEVEL = INFO
#: time format used in log records: "LOCAL" or "UTC"
LOG_TIME = LOCAL
#: maximum log file size in megabytes before performing rotation (0 - without rotation)
MAX_LOG_FILE_SIZE = 1024
#: [integer] send log to stdout
LOG_TO_STDOUT = 1
#: [integer] send log to file
LOG_TO_FILE = 0
#: [integer] allow multiline stack trace in logs
MULTILINE_STACK_TRACE = 1


[LUNA_BACKPORT3_DB]

#: type of database: "postgres" or "oracle"; "postgres" type is used by default
DB_TYPE = postgres
#: database username
DB_USER = luna
#: database password
DB_PASSWORD = luna
#: database name for "postgres" type, SID name for "oracle" type
DB_NAME = luna_backport3
#: database IP address
DB_HOST = 127.0.0.1
#: database listener port, 5432 - default for "postgres" type, 1521 - default for "oracle" type
DB_PORT = 5432


[LUNA_BACKPORT3_DB.DB_SETTINGS]

#: [integer] database connection pool size
CONNECTION_POOL_SIZE = 5



[LUNA_MONITORING]

#: [string] storage type
STORAGE_TYPE = influx
#: [integer] send data for monitoring to InfluxDB
SEND_DATA_FOR_MONITORING = 1
#: [string] InfluxDB 2.x workspace
ORGANIZATION = luna
#: [string] InfluxDB 2.x authentication token
TOKEN = kofqt4Pfqjn6o0RBtMDQqVoJLgHoxxDUmmhiAZ7JS6VmEnrqZXQhxDhad8AX9tmiJH6CjM7Y1U8p5eSEocGzIA==
#: [string] InfluxDB 2.x bucket name
BUCKET = luna_monitoring
#: [string] InfluxDB IP address
HOST = 127.0.0.1
#: [integer] InfluxDB port
PORT = 8086
#: [integer] use HTTPS to connect to InfluxDB
USE_SSL = 0
#: [integer] frequency of sending monitoring data to InfluxDB (in seconds)
FLUSHING_PERIOD = 1


[LUNA_API_ADDRESS]

#: LUNA API protocol, IP address, and port
ORIGIN = http://127.0.0.1:5000
#: API version of the LUNA API
API_VERSION = 6


[LUNA_API_TIMEOUTS]

#: CONNECT TIMEOUT
CONNECT = 30
#: REQUEST TIMEOUT (total)
REQUEST =  60


[LUNA_IMAGE_STORE_PORTRAITS_ADDRESS]

#: LUNA Image Store protocol, IP address, and port (for samples)
ORIGIN = http://127.0.0.1:5020
#: API version of the LUNA Image Store (for samples)
API_VERSION = 1
#: *bucket* name, where samples will be stored
BUCKET = portraits


[LUNA_IMAGE_STORE_PORTRAITS_TIMEOUTS]

#: CONNECT TIMEOUT
CONNECT = 30
#: REQUEST TIMEOUT (total)
REQUEST =  60


[BACKPORT3_EVENTS_DB_ADDRESS]

#: redis host for the service subscription
HOST = 127.0.0.1
#: redis port for the service subscription
PORT = 6379
#: [string] redis username for the service subscription
USER =
#: redis password for the service subscription
PASSWORD =
#: redis channel for the service subscription
CHANNEL = luna-backport3


[BACKPORT3_EVENTS_DB_ADDRESS.SENTINEL]
#: [string] sentinel master name
MASTER_NAME = luna_tasks
#: [list(string)] list of Redis Sentinel listeners (example [127.0.0.1:26379, 10.0.4.1:26379]).
#: By setting this parameter, application will query Redis parameters (host and port) from sentinels
SENTINELS = []
#: [string] sentinel username
USER =
#: [string] sentinel password
PASSWORD =


[LUNA_BACKPORT3_HTTP_SETTINGS]

#: [integer] service request timeout (in seconds)
REQUEST_TIMEOUT = 60
#: [integer] service response timeout (in seconds)
RESPONSE_TIMEOUT = 600
#: [integer] max request size (in bytes), default 1gb
REQUEST_MAX_SIZE = 1073741824
#: [integer] service http keep-alive timeout (in seconds)
KEEP_ALIVE_TIMEOUT = 15


[LUNA_SERVICE_METRICS]

#: [int] whether to enable /metrics path and statistics collection
ENABLED = 0
# [string] statistics data format (prometheus is the only option yet)
METRICS_FORMAT = prometheus


[LUNA_SERVICE_METRICS.EXTRA_LABELS]


[OTHER]

#: storage time - "LOCAL" or "UTC"
STORAGE_TIME = LOCAL
#: Use samples as portraits
USE_SAMPLES_AS_PORTRAITS = 1
#: Max candidate count into a response on matching request
MAX_CANDIDATE_IN_RESPONSE = 5
#: Whether to enable ws events support
BACKPORT3_ENABLE_WS_EVENTS = 1
#: Whether to enable portraits support
BACKPORT3_ENABLE_PORTRAITS = 1
#: Whether to use handlers
LUNA_BACKPORT3_USE_HANDLERS = 1
#: list of active plugins
LUNA_BACKPORT3_ACTIVE_PLUGINS = []
#: whether to store events
LUNA_BACKPORT3_STORE_EVENTS = 0

Run service

See the instruction launch service

Test service

See the instruction test service

Deploy service

See the information about different ways to deploy the service deploy service