Skip to content

Commit 84f91d8

Browse files
committed
update entrypoint and dataset setup, make cache optional
1 parent 8f279d8 commit 84f91d8

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

msc-wis2node-management/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ ARG SR3_CONFIG /home/msc-wis2node/.config/sr3
2525

2626
ENV TZ="Etc/UTC" \
2727
DEBIAN_FRONTEND="noninteractive" \
28-
DEBIAN_PACKAGES="bash curl git python3-pip python3-setuptools sudo vim"
28+
DEBIAN_PACKAGES="bash curl git python3-pip python3-setuptools sudo vim" \
29+
MSC_WIS2NODE_DATASET_CONFIG=/home/msc-wis2node/datasets.yml
2930

3031
# copy the app
3132
COPY ./ /app

msc-wis2node-management/docker/entrypoint.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ printenv | grep -v "no_proxy" > /tmp/environment
2424
sudo sh -c 'cat /tmp/environment >> /etc/environment'
2525
rm -f /tmp/environment
2626

27-
echo "starting sr3..."
27+
echo "Setting up MSC dataset config"
28+
msc-wis2node dataset setup
2829

30+
echo "starting sr3..."
2931
sr3 --logStdout start subscribe/dd.weather.gc.ca-all && sleep infinity
3032

3133
echo "END /entrypoint.sh"

msc-wis2node-management/msc_wis2node/publisher.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ class WIS2Publisher:
7676
def __init__(self):
7777
"""initialize"""
7878

79-
self.cache = memcache_base.Client(CACHE)
79+
self.cache = None
8080
self.datasets = []
8181
self.tls = None
8282

8383
self.client_id = get_mqtt_client_id()
8484

85+
if CACHE is not None:
86+
self.cache = memcache_base.Client(CACHE)
87+
8588
if BROKER_PORT == 8883:
8689
self.tls = get_mqtt_tls_settings()
8790

@@ -181,14 +184,15 @@ def publish_to_wis2(self, dataset: dict, url: str) -> None:
181184
url=url
182185
)
183186

184-
LOGGER.debug('Checking for data update')
185-
if self.cache.get(message['properties']['data_id']) is not None:
186-
update_link = deepcopy(message['links'][0])
187-
update_link['rel'] = 'update'
188-
message['links'].append(update_link)
189-
else:
190-
self.cache.set(message['properties']['data_id'],
191-
CACHE_EXPIRY_SECONDS)
187+
if self.cache is not None:
188+
LOGGER.debug('Checking for data update')
189+
if self.cache.get(message['properties']['data_id']) is not None:
190+
update_link = deepcopy(message['links'][0])
191+
update_link['rel'] = 'update'
192+
message['links'].append(update_link)
193+
else:
194+
self.cache.set(message['properties']['data_id'],
195+
CACHE_EXPIRY_SECONDS)
192196

193197
cache = dataset.get('cache', True)
194198
if not cache:

msc-wis2node-management/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ certifi
33
click
44
metpx-sr3
55
pywis-pubsub
6+
pymemcache

0 commit comments

Comments
 (0)