Installation

Follow these steps to install and configure LUNA Events and its database:

1 Install Python

Python of version 3.10 is required.

2 Install database

PostgreSQL of version 9.6 or higher is required.

  • Install the repository RPM:

    sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    
  • Install the client packages for PostgreSQL:

    PostgreSQL 12:

    yum -y install postgresql12 postgresql12-server
    
    /usr/pgsql-12/bin/postgresql-12-setup initdb
    
  • Configure the database availability in file “/var/lib/pgsql/12/data/pg_hba.conf”

  • Launch PostgreSQL:

    systemctl start postgresql-12
    
    systemctl enable postgresql-12
    
  • Install PostGIS (depends on Postgresql version)

    for PostgreSQL 12:

    sudo yum -y install postgis25_12
    
  • Create user and database:

    psql -U postgres;
    
    create role luna;
    ALTER USER luna WITH PASSWORD 'luna';
    CREATE DATABASE luna_events;
    GRANT ALL PRIVILEGES ON DATABASE luna_events TO luna;
    ALTER ROLE luna WITH LOGIN;
    
  • Activate PostGIS:

    runuser -u postgres -- psql -d luna_events -c "CREATE EXTENSION postgis;";
    

3 Install Python libraries

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

  • Go to the project source directory:

cd /var/lib/luna/current/luna-events
  • Create a virtual environment:

python3 -m venv venv
  • Add the path to the PostgreSQL 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 (for PostgreSQL). The configurations are received using the Configurator service:

python ./base_scripts/db_create.py --luna-config http://127.0.0.1:5070/1
  • Use the following command for the virtual environment deactivation:

deactivate

5 Check configs

Check and change the service settings in the configuration file /var/lib/luna/current/luna-events/luna_events/configs/config.conf (if necessary):

#: LUNA Events configuration file

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

[LUNA_EVENTS_LOGGER]

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


[LUNA_EVENTS_DB]

#: [string] type of database: "postgres"
DB_TYPE = postgres
#: [string] login to database
DB_USER = luna
#: [string] database password
DB_PASSWORD = luna
#: [string] database IP address
DB_HOST = 127.0.0.1
#: [integer] database listener port, 5432 - default for "postgres" type
DB_PORT = 5432
#: [string] database name
DB_NAME = luna_events


[LUNA_EVENTS_DB.DB_SETTINGS]

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


[INFLUX_MONITORING]

#: [integer] send data for monitoring to InfluxDB
SEND_DATA_FOR_MONITORING = 1
#: [string] InfluxDB 2.x workspace
ORGANIZATION =
#: [string] InfluxDB 2.x authentication token
TOKEN =
#: [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] period of sending monitoring data to the InfluxDB (in seconds)
FLUSHING_PERIOD = 1


[OTHER]

#: [string] time format used in database records: "LOCAL" or "UTC"
STORAGE_TIME = LOCAL
#: [integer] default face descriptor version
DEFAULT_FACE_DESCRIPTOR_VERSION = 59
#: [integer] default human body descriptor version
DEFAULT_HUMAN_DESCRIPTOR_VERSION = 104
#: [float] save events timeout. 0 or negative means no timeout
SAVE_EVENTS_TIMEOUT = -1
#: [list(string)] list of active plugins
LUNA_EVENTS_ACTIVE_PLUGINS = []