Skip to content

Commit

Permalink
add collector URL env var
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 19, 2024
1 parent d8c1ab2 commit 0715e05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion wis2-gdc-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENV PYGEOAPI_OPENAPI=/pygeoapi/local.openapi.yml

RUN apt-get update && \
apt-get install -y curl && \
pip3 install pywcmp && \
pip3 install -r requirements.txt && \
pywcmp bundle sync

COPY ./wis2-gdc-api.yml /pygeoapi/local.config.yml
Expand Down
12 changes: 7 additions & 5 deletions wis2-gdc-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

import os

from flask import Flask, send_file
from flask import Flask, Response, send_file
from pygeoapi.flask_app import BLUEPRINT as pygeoapi_blueprint
import requests

app = Flask(__name__, static_url_path='/static')
app.url_map.strict_slashes = False
Expand Down Expand Up @@ -50,9 +51,10 @@ def archive():
@app.route('/wis2-gdc-metrics.txt')
def metrics():

metrics_file = os.environ.get('WIS2_GDC_OPENMETRICS_FILE')
collector_url = os.environ.get('WIS2_GDC_COLLECTOR_URL')

try:
return send_file(metrics_file, mimetype='text/plain')
except FileNotFoundError:
return 'Not Found', 404
response = requests.get(collector_url).text
return Response(response, mimetype='text/plain')
except Exception:
return 'Internal Server Error', 500
2 changes: 2 additions & 0 deletions wis2-gdc-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pywis-pubsub
requests
1 change: 1 addition & 0 deletions wis2-gdc.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export WIS2_GDC_BACKEND_TYPE=Elasticsearch
export WIS2_GDC_BACKEND_CONNECTION=http://elasticsearch:9200/wis2-discovery-metadata
export WIS2_GDC_BROKER_URL=mqtt://wis2-gdc:wis2-gdc@wis2-gdc-broker:1883
export WIS2_GDC_CENTRE_ID=ca-eccc-msc-global-discovery-catalogue
export WIS2_GDC_COLLECTOR_URL=http://wis2-gdc-metrics-collector:8006
export WIS2_GDC_GB=mqtts://everyone:everyone@globalbroker.meteo.fr:8883
export WIS2_GDC_GB_TOPIC=origin/a/wis2/+/metadata/#
export WIS2_GDC_METADATA_ARCHIVE_ZIPFILE=/data/wis2-gdc-archive.zip
Expand Down

0 comments on commit 0715e05

Please sign in to comment.