Skip to main content

Standalone

Standalone mode only deploys the Python script. You should install and configure Prometheus and Grafana (or another tools if you want) by yourself to have the stack described in the Design section.

tip

You can use virtualenv to install and run the app in an isolated environment

Requirements

  • Windows, Linux or macOS
  • Python3 (version 3.8, 3.9 and 3.10 are tested)

Preparing Steps

  1. Download the source code of the project from the latest release and extract it.

  2. Move to the downloaded folder and execute this command in app folder:

python3 -m pip install -r requirements.txt
  1. Write a config.yaml (name can't be changed) following this doc in one of the following paths :
  • ~/.config/app/SuiviBourse
  • /etc/app/SuiviBourse
info

To know more about config file location, please refer to the confuse library documentation

Running the app

You can simply run the app with the following command inside the project's root folder :

python3 app/src/main.py 

However, we recommend chosing between the following methods to run the standalone app in production.

Replace <installation_path> with the path of the folder where you download and extract the project folder (see step 1 of preparing step)

Almost all versions of Linux come with systemd out of the box, but if your’s didn’t come with it then you can simply install it. You should have a regular, non-root user with sudo privileges configured or access to root user to perform this.

Replace <user> and <group> with the user and the group of the user with whom you ran the step 2.

  1. Create a user service unit file in /etc/systemd/system/suivi-bourse.service:

    [Unit]
    Description=SuiviBourse

    [Service]
    Type=simple
    Restart=always
    ExecStart=/usr/bin/python3 <installation_path>/app/src/main.py
    User=<user>
    Group=<group>
    Environment=PYTHONUNBUFFERED=1
    SyslogIdentifier=suivi-bourse

    [Install]
    WantedBy=default.target
  2. Reload systemd-daemon:

    systemctl daemon-reload
  3. Enable the service at boot:

    systemctl enable suivi-bourse 
  4. Start the service:

    systemctl start suivi-bourse

You can see the application logs in /var/log/syslog and check the status with systemctl status suivi-bourse

Environment variables

Env variables can be used to override some default parameters :

ENVDescriptionDefault Value
SB_METRICS_PORTPort TCP used to expose data8081
SB_SCRAPING_INTERVALInterval in seconds where app gets data from Yahoo! Finance API120
LOG_LEVELApp log levelINFO

Prometheus configuration

Add a static config to your Prometheus instance, to scrape data expoed by the app. Below, an example of configuration :

scrape_configs:
- job_name: 'suivi-bourse'
scrape_interval: '120s'
static_configs:
- targets: ['localhost:8081']

Grafana dashboard

Depending on your Grafana version, you can add this dashboard to vizualise app metrics :

From Version 9.x, the dashboard uses the Candlestick panel instead of the TimeSeries panel