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.
- Prerequisites
- Run locally with Python
- Run locally with Docker
- Run on Kubernetes
- Troubleshooting
- Built with
- Contributing
- License
You can run this solution locally in docker as follows
-
Set up environment variables in the
.env
file -
Install mariadb locally
- build
docker pull mariadb
- 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
- 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
- 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
-
Create python virtual environment
python3 -m venv python3
-
Activate virtual environment
source python3/bin/activate
-
Run the application
python src/manage.py start 3000
-
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)
- 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
- Build the image
docker build . -t webapp
- Run the image
docker run -p3000:3000 -t webapp
- 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
- Test by opening "http://0.0.0.0:3000" in a browser
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
- Database does not connect
- ensure
.env
file has the correct values for database connection
- ensure
- Change the db password
- Docker
- MariaDB
- Flask
- IBM Kubernetes Service
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting Prometeo pull requests.
This project is licensed under the Apache 2 License - see the LICENSE file for details.