Service launch

Launch service using configuration file

The service is launched using the run.py script.

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

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

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

In this example:

  • The service is launched using Python. Note, that Python version must be 3.12 or higher;

  • The service is launched on port 5000. 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.

Additionally, service can be started with the https protocol by passing a certificate, a private key, and a password to the private key in command-line arguments:

  • tls_cert - path to ssl certificate

  • tls_key - path to ssl private key

  • tls_key_pass - ssl private key password (optional)

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

Note

You also have the option to specify environment variables using command line arguments, as shown in the example below. Please be warned that Bash does not accept variable names containing a dot (‘.’) symbol, which forces us to use env “<variable>=<value>” shell construct.

This hack has a side effect that restarts the shell and therefore rebuilds the entire environment. Thus, we first define env “<variable>=<value>” bash. Then, we proceed with the rest variables to prevent losing them. The shell restart happens with each env “<variable>=<value>” bash command call, so the variables must be specified one after another in one call, as shown in the example below.

NOTA BENE: Sometimes Bash starts with its own parameters, so we better add **args at the end of the script just in case

env setting=value \
    "VL_SETTINGS.LUNA_CONFIGURATOR.LUNA_CONFIGURATOR_USER=your_username" \
    "VL_SETTINGS.LUNA_CONFIGURATOR.LUNA_CONFIGURATOR_PASS=your_password" \
    bash **args

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.

To specify the Configurator service address and port, use the following command:

python run.py --port=5001 --luna-config http://127.0.0.1:5071/1 --log_suffix=test --use_detector=1

Where http://127.0.0.1:5071 is the available Configurator service address and 1 is the Configurator API version. By default the Configurator service is launched on the 5070 port.

It is possible to disable detector, extractor, estimator by using use_detector, use_extractor, use_estimator parameters (it needs 0 as parameter’s value to disable). For default, detector, extractor and estimator are enabled.

Running service on a port with configuration file and output to log files having suffix “test”. Port, path to configuration file and custom log files’ suffix are set as command line arguments.

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

Check connections to required services

The service check connections to all required services before starting by default. This eliminates errors caused by incorrect system configuration. If need to disable this feature you can set an environment variable LUNA_SKIP_CHECK_CONNECTION to “1”.