Skip to content

Commit

Permalink
wis2box with wis2box-webapp
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed Jul 29, 2023
1 parent 7c709b8 commit a99c22f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
16 changes: 13 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ services:
depends_on:
- wis2box-api

wis2box-webapp:
container_name: wis2box-webapp
image: wis2box-webapp:latest
env_file:
- default.env
- dev.env
depends_on:
- wis2box-api

# wis2box-ui-admin:
# container_name: wis2box-ui-admin
# image: ghcr.io/wmo-im/wis2box-ui-admin:latest
Expand All @@ -33,16 +42,17 @@ services:

wis2box-api:
container_name: wis2box-api
image: ghcr.io/wmo-im/wis2box-api:latest
image: wis2box-api:latest
#image: ghcr.io/wmo-im/wis2box-api:latest
restart: always
env_file:
- default.env
- dev.env
depends_on:
elasticsearch:
condition: service_healthy
volumes:
- api-config:/data/wis2box/config/pygeoapi/:rw
#volumes:
# - api-config:/data/wis2box/config/pygeoapi/:rw
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/oapi/admin/resources"]
interval: 5s
Expand Down
7 changes: 5 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
auth_request_set $auth_status $upstream_status;
proxy_pass http://wis2box-api:80;
}
location / {
proxy_pass http://wis2box-ui:80;
location /wis2box-webapp/ {
proxy_pass http://wis2box-webapp:4173/wis2box-webapp/;
}
# location /admin/ {
# proxy_pass http://wis2box-ui-admin:80/;
Expand All @@ -76,4 +76,7 @@
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
}
location / {
proxy_pass http://wis2box-ui:80;
}
}
7 changes: 4 additions & 3 deletions wis2box-management/wis2box/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ def notify(self, identifier: str, storage_path: str,
}
local_broker = load_plugin('pubsub', defs_local)
local_broker.pub('wis2box/notifications',
json.dumps(notify_msg),
json.dumps(wis_message),
qos=0)

LOGGER.debug('Pushing message to API')
upsert_collection_item('messages', wis_message.message)
# this will be handled by subscriber via the wis2box/notifications topic
# LOGGER.debug('Pushing message to API')
# upsert_collection_item('messages', wis_message.message)

return True

Expand Down
36 changes: 23 additions & 13 deletions wis2box-management/wis2box/pubsub/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import click

from wis2box import cli_helpers

from wis2box.api import upsert_collection_item
from wis2box.api import setup_collection
from wis2box.env import (BROKER_HOST, BROKER_PORT, BROKER_USERNAME,
BROKER_PASSWORD, STORAGE_SOURCE, STORAGE_ARCHIVE)
Expand Down Expand Up @@ -61,21 +63,28 @@ def handle(filepath):
def on_message_handler(client, userdata, msg):
LOGGER.debug(f'Raw message: {msg.payload}')

topic = msg.topic
message = json.loads(msg.payload)

if message.get('EventName') == 's3:ObjectCreated:Put':
LOGGER.debug('Incoming data is an s3 data object')
key = str(message['Key'])
filepath = f'{STORAGE_SOURCE}/{key}'
if key.startswith(STORAGE_ARCHIVE):
LOGGER.info(f'Do not process archived-data: {key}')
return
elif 'relPath' in message:
LOGGER.debug('Incoming data is a filesystem path')
filepath = Path(message['relPath'])

LOGGER.info(f'Incoming message on topic {topic}')
if topic == 'wis2box/notifications':
LOGGER.info(f'Notification: {message}')
# store notification in messages collection
upsert_collection_item('messages', message)
else:
LOGGER.warning('message payload could not be parsed')
return
if message.get('EventName') == 's3:ObjectCreated:Put':
LOGGER.debug('Incoming data is an s3 data object')
key = str(message['Key'])
filepath = f'{STORAGE_SOURCE}/{key}'
if key.startswith(STORAGE_ARCHIVE):
LOGGER.info(f'Do not process archived-data: {key}')
return
elif 'relPath' in message:
LOGGER.debug('Incoming data is a filesystem path')
filepath = Path(message['relPath'])
else:
LOGGER.warning('message payload could not be parsed')
return

while len(mp.active_children()) == mp.cpu_count():
sleep(0.1)
Expand Down Expand Up @@ -107,3 +116,4 @@ def subscribe(ctx, broker, topic, verbosity):
broker.bind('on_message', on_message_handler)

broker.sub(topic)
broker.sub('wis2box/notifications')
2 changes: 1 addition & 1 deletion wis2box-mqtt-metrics-collector/mqtt_metrics_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def sub_mqtt_metrics(client, userdata, msg):
update_stations_gauge(m['station_list'])
elif str(msg.topic).startswith('wis2box/notifications'):
notify_wsi_total.labels(
m['wigos_station_identifier']).inc(1)
m['properties']['wigos_station_identifier']).inc(1)
notify_total.inc(1)
elif str(msg.topic).startswith('wis2box/failure'):
descr = m['description']
Expand Down

0 comments on commit a99c22f

Please sign in to comment.