Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Latest commit

 

History

History
145 lines (125 loc) · 5.15 KB

README.md

File metadata and controls

145 lines (125 loc) · 5.15 KB

Prometeo Web App

This repository contains the Prometeo solution web application dashboard for firefighters to view .

This service wakes up every minute and calculates time weighted average exposures for all fire fighters and compares them to the configured limits.

License Slack

Contents

Prerequisites

  1. Docker
  2. IBM CLI
  3. Kubectl
  4. Helm
  5. Skaffold

Run locally with Python

You can run this solution locally in docker as follows

  1. Set up environment variables in the .env file

  2. Install mariadb locally

    1. build
        docker pull mariadb
    
    1. run the image
        docker run -p 3306:3306 --name prometeo-mariadb -e MYSQL_ROOT_PASSWORD='' -d mariadb
        FYI: MYSQL_ROOT_PASSWORD is the initial password you want to set for the db login
    
    1. Test the image by logging into the container once it is running
    docker exec -it prometeo-mariadb mysql -uroot -p
    FYI: This command might also useful for loading the dump
    
    1. Use the prometeo.sql and procedure.sql to dump into the new database to get the initial framework set from https://github.com/Code-and-Response/Prometeo-Database
  3. Create python virtual environment

         python3 -m venv python3
    
  4. Activate virtual environment

         source python3/bin/activate
    
  5. Run the application

         python src/manage.py start 3000
    
  6. You should see the following output

         starting application
         * Serving Flask app "core_decision_flask_app" (lazy loading)
         * Environment: production
         WARNING: Do not use the development server in a production environment.
         Use a production WSGI server instead.
         * Debug mode: off
         * Running on http://0.0.0.0:3000/ (Press CTRL+C to quit)
    

Run locally with Docker

  1. Build the local .env file
    MARIADB_HOST= <node port ip>
    MARIADB_USERNAME=root
    MARIADB_PASSWORD=<password>
    MARIADB_PORT=31672
    WS_HOST=<WS://>
    WS_PORT=8080
    
  2. Build the image
        docker build . -t webapp
    
  3. Run the image
         docker run -p3000:3000 -t webapp
    
  4. You should see the application logs
         2020-09-23 18:02:12 +0000] [9] [INFO] Starting gunicorn 19.7.1
     [2020-09-23 18:02:12 +0000] [9] [INFO] Listening at: http://0.0.0.0:3000 (9)
     [2020-09-23 18:02:12 +0000] [9] [INFO] Using worker: sync
     [2020-09-23 18:02:12 +0000] [12] [INFO] Booting worker with pid: 12
     INFO:prometeo.fuel_types.fuelTypes:creating an instance of fuelTypes
     INFO:prometeo.fuel_types.fuelTypes:calling the stored procedure
     DEBUG:prometeo.fuel_types.fuelTypes:there is data:
     DEBUG:prometeo.fuel_types.fuelTypes:(1, 'Pinar', None)
     DEBUG:prometeo.fuel_types.fuelTypes:(2, 'Matojo', None)
     DEBUG:prometeo.fuel_types.fuelTypes:(3, 'Campo de trigo', None)
     DEBUG:prometeo.status.status_webapp:creating an instance of status
     get_allstatus - entro en la funcion
     get_allstatus - llamada a sql
     get_allstatus - Hay informacion
     (1, 'Planificado', None)
     (2, 'En curso', None)
     (3, 'Finalizado', None)
     (4, 'Cancelado', None)
     DEBUG:prometeo.eventTypes.event_Types:creating an instance of eventTypes
     get_alleventTypes - entro en la función
     get_alleventTypes - llamada a sql
     get_alleventTypes - Hay informacion
     (1, 'Quema Prescrita', None)
     (2, 'Incendio Forestal', None)
     WARNING:ibmcloudenv:The specified config.json file /app/server/config/mappings.json does not exist
    
  5. Test by opening "http://0.0.0.0:3000" in a browser

Run on Kubernetes

You can run this application on Kubernetes. The skaffold.yaml file let's you quickly run the application on the cluster by using Skaffold. There are two profiles provided. To run the solution on the test namespace use: skaffold dev -p test

Troubleshooting

  1. Database does not connect
    1. ensure .env file has the correct values for database connection
  2. Change the db password

Built with

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting Prometeo pull requests.

License

This project is licensed under the Apache 2 License - see the LICENSE file for details.