Skip to content

Commit

Permalink
abstract zipfile location to env var, add metrics API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkralidis committed Mar 13, 2024
1 parent 5ca430d commit 115d1cc
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
7 changes: 6 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ services:
depends_on:
elasticsearch:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://elasticsearch:9200/wis2-discovery-metadata"]
interval: 5s
retries: 3
volumes:
- wis2-gdc-management-data:/data
restart: always
Expand All @@ -84,7 +88,8 @@ services:
context: wis2-gdc-api/
image: geopython/pygeoapi:latest
depends_on:
- wis2-gdc-management
wis2-gdc-management:
condition: service_healthy
volumes:
- wis2-gdc-management-data:/data
healthcheck:
Expand Down
21 changes: 12 additions & 9 deletions docker/wis2-gdc-api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
#
###############################################################################

from flask import Flask, make_response, redirect
import os

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

app = Flask(__name__, static_url_path='/static')
Expand All @@ -37,14 +39,15 @@
@app.route('/wis2-discovery-metadata-archive.zip')
def archive():

headers = {
'Content-Type': 'application/zip'
}
zip_file = os.environ.get('WIS2_GDC_METADATA_ARCHIVE_ZIPFILE')

return send_file(zip_file, mimetype='application/zip', add_etags=True)


with open('/data/wis2-discovery-metadata-archive.zip') as fh:
response = make_response(fh.read(), 200)
response.headers = headers
@app.route('/wis2-gdc-metrics.txt')
def metrics():

return response
metrics_file = os.environ.get('WIS2_GDC_OPENMETRICS_FILE')

return redirect('https://docs.wis2box.wis.wmo.int', code=302)
return send_file(metrics_file, mimetype='text/plain',
add_etags=True)
6 changes: 6 additions & 0 deletions docker/wis2-gdc-api/wis2-gdc-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ resources:
href: ${WIS2_GDC_API_URL}/wis2-discovery-metadata-archive.zip
hreflang: en-CA
length: -1
- type: text/plain
rel: related
title: WIS2 Global Discovery Catalogue metrics
href: ${WIS2_GDC_API_URL}/{WIS2_GDC_OPENMETRICS_FILE}
hreflang: en-CA
extents:
extents:
spatial:
bbox: [-180, -90, 180, 90]
Expand Down
2 changes: 1 addition & 1 deletion docker/wis2-gdc-management.cron
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0 0 * * * su -c "wis2-gdc archive /data/wis2-discovery-metadata-archive.zip" > /proc/1/fd/1 2>/proc/1/fd/2
0 0 * * * su -c "wis2-gdc archive $WIS2_GDC_METADATA_ARCHIVE_ZIPFILE" > /proc/1/fd/1 2>/proc/1/fd/2
3 changes: 2 additions & 1 deletion docker/wis2-gdc.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export WIS2_GDC_BACKEND_CONNECTION=http://elasticsearch:9200/wis2-discovery-meta
export WIS2_GDC_BROKER_URL=mqtt://wis2-gdc:wis2-gdc@mosquitto:1883
export WIS2_GDC_CENTRE_ID=ca-eccc-msc-gdc
export WIS2_GDC_GB=mqtt://everyone:everyone@mosquitto:1883
export WIS2_GDC_GB_TOPIC=origin/a/wis2/+/+/metadata/#
export WIS2_GDC_GB_TOPIC=origin/a/wis2/+/metadata/#
export WIS2_GDC_OPENMETRICS_FILE=/tmp/wis2-gdc-openmetrics.txt
export WIS2_GDC_METADATA_ARCHIVE_ZIPFILE=/data/wis2-discovery-metadata-archive.zip
export WIS2_GDC_PUBLISH_REPORTS=true

# global broker links
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
click
prometheus-client
pywcmp
pywis-pubsub
requests
Expand Down
5 changes: 3 additions & 2 deletions wis2-gdc.env
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export WIS2_GDC_API_URL=http://localhost
export WIS2_GDC_API_URL_DOCKER=http://wis2-gdc-api
export WIS2_GDC_BACKEND_TYPE=Elasticsearch
export WIS2_GDC_BACKEND_CONNECTION=http://localhost:9200/wis2-discovery-metadata
export WIS2_GDC_BROKER_URL=mqtt://wis2-gdc:wis2-gdc@localhost:1883
export WIS2_GDC_BACKEND_CONNECTION=http://elasticsearch:9200/wis2-discovery-metadata
export WIS2_GDC_BROKER_URL=mqtt://wis2-gdc:wis2-gdc@mosquitto:1883
export WIS2_GDC_CENTRE_ID=ca-eccc-msc-global-discovery-catalogue
export WIS2_GDC_GB=mqtt://everyone:everyone@localhost:1883
export WIS2_GDC_GB_TOPIC=origin/a/wis2/+/metadata/#
export WIS2_GDC_OPENMETRICS_FILE=/tmp/wis2-gdc-openmetrics.txt
export WIS2_GDC_METADATA_ARCHIVE_ZIPFILE=/tmp/wis2-discovery-metadata.zip
export WIS2_GDC_PUBLISH_REPORTS=true
export WIS2_GDC_REJECT_ON_FAILING_ETS=true
export WIS2_GDC_RUN_KPI=true
Expand Down

0 comments on commit 115d1cc

Please sign in to comment.