# Luna Streams v.0.6.21 documentation

## Installation

For proper installation you need to clone project from git.

## Surroundings

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

Required predefined dependencies:

- Developer package postgresql (for psycopg2 installation, if you use postgresql as database), in CentOS 7 you can execute following command:

    yum install postgresql-server gcc python34-devel file postgresql postgresql-devel

- Python 3.11 is required.

- It is strongly recommended to create virtual surroundings for python dependencies installation.

- Python setuptools module can be installed via pip (pip install setuptools).

## Dependencies installation

After surroundings installation launch setup.py with install parameter.

    python setup.py install

If surrounding is installed correctly, this script will install all dependencies and carry out versioning automatically.

If all dependencies are already installed and only versioning is required, launch versioneer.py script with version parameter from root folder. Please note that for versioning git files are required.

If you need to install dependencies without versioning, you should use dependencies file placed in luna_streams.egg-info

    pip install -r requires.txt

## Configuration

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

## Database creation

All databases for service must be created in accordance with “./luna_streams/configs/config.conf”.

- Postgresql (require version 9.6 or higher)

- Oracle (require version Oracle Database Express Edition 11g or higher)

Create all required schemes in postgresql. If database or user is not created yet, one should execute the following commands with “user name” and “database” from the config file (for example, config.conf with “luna” and “luna_streams”):

    psql -U postgres;

    create role luna;
    ALTER USER luna WITH PASSWORD 'luna';
    CREATE DATABASE luna_streams;
    GRANT ALL PRIVILEGES ON DATABASE luna_streams TO luna;
    ALTER ROLE luna WITH LOGIN;

Activate PostGIS:

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

Then launch db_create.py script for tables and primal data creation:

    python ./base_scripts/db_create.py

If script was executed without errors, all schemes were created successfully. db_create also creates scripts for further database migration (db_repository folder), without these db migration execution is impossible.

## First launch and testing

If all previous actions are executed successfully, server is ready to work. To start server please launch run.py script. While start you can add arguments: server message port, path to config, suffix for log files (for different workers). By default 5160 port is used. Also it possible to run service with config from luna-configurator (see configurator).

Example:

    ./run.py --port 5160 --config ./configs/myconfig.conf --log_suffix 1

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

    python -m unittest tests.unittests_main

All tests should perform successfully.