Service launch

Launch service using configuration file

The service is launched using the run.py script.

The virtual environment for the service must be activated before the script launch.

The example of service launch from the service directory (“/var/lib/luna/current/luna-events/luna_events/”) is given below:

python run.py --port=5040 --config=./configs/myconfig.conf --log_suffix=test

In this example:

  • The service is launched using Python;

  • The service is launched on port 5040. It is the default port for the service;

  • Custom configuration file “myconfig.conf” is set using the relative path to the service directory. If there is no “–config” argument specified, the default configuration file “config.conf” is used. You can also use configs from the Configurator service (see Launch service using Configurator);

  • The output will be written to the log files with the “test” suffix.

Port, configuration file path and custom suffix for log files are set as command-line arguments. You can view help to find out more about command-line arguments using the following command:

python run.py --help

or

python run.py -h

Launch service using Configurator

It is possible to run service with the config received from the Configurator service.

To use the Configurator service for service launching, do not pass config param to run service, use “luna-config” instead of it.

Simple service launching with the Configurator service: (It works if the Configurator service has been launched at localhost on the 5070 port)

python run.py

To specify the Configurator service address and port, use:

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

Where http://127.0.0.1:5071 is the available Configurator service address and 1 is the Configurator API version.

If one does not pass –luna-config command-line argument, it can be specified in the [LUNA_CONFIGURATOR] section of a config file. While the value of USE_CONFIGURATOR is set to “0”, the settings from the configuration file are used. Otherwise, the settings from the Configurator service are used.

Set non-default setting in Configurator

It is possible to specify a tag for every setting to get the non-default setting. (see the LUNA Configurator documentation for more information). Example:

python run.py --INFLUX_MONITORING TAG_1

Where INFLUX_MONITORING is the setting name and TAG_1 is the desired tag for this setting.

See the full list of available tags using the following command:

python run.py --help

Tests

  1. Go to the project directory:

cd /var/lib/luna/current/luna-events/
  1. Ensure that the Events service is running.

  2. Check and, if necessary, change the test settings in the tests/config.py configuration file:

  • SERVER_ORIGIN = ‘<the Luna Events server origin>’

  • SERVER_API_VERSION = ‘<the Luna Events server api version>’

  • STORAGE_TIME = ‘<time in which records are stored in the database: LOCAL or UTC>’

  • DB_NAME = ‘<service database: postgres>’

  1. Activate the virtual environment

  2. Run tests by the command

python -m unittest tests.unittests_main

For api reference usage see luna-events.