From 82afee521de08d5dfa9c9496344240ed25ff81fb Mon Sep 17 00:00:00 2001 From: Gerrit Holl Date: Wed, 22 Dec 2021 18:15:17 +0100 Subject: [PATCH] Add support for publisher config Add an option to use publisher configuration from a file. Needs merger of posttroll #35 https://github.com/pytroll/posttroll/pull/35 --- bin/viirs_dr_runner.py | 5 ++++- cspp_runner/runner.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/viirs_dr_runner.py b/bin/viirs_dr_runner.py index 9bf98c1..dcb36b7 100755 --- a/bin/viirs_dr_runner.py +++ b/bin/viirs_dr_runner.py @@ -61,6 +61,8 @@ def parse_args(): type=str, default=None, help="The file to log to (stdout per default).") + parser.add_argument("-p", "--publisher", type=str, + help="File with publisher config (YAML).") return parser.parse_args() @@ -134,7 +136,8 @@ def main(): viirs_sdr_call, viirs_sdr_options, int(OPTIONS.get("granule_time_tolerance", 10)), - int(OPTIONS.get("ncpus", 1)) + int(OPTIONS.get("ncpus", 1)), + publisher_config=args.publisher, ) diff --git a/cspp_runner/runner.py b/cspp_runner/runner.py index ca9f4ed..c119fee 100644 --- a/cspp_runner/runner.py +++ b/cspp_runner/runner.py @@ -580,6 +580,7 @@ def npp_rolling_runner( viirs_sdr_options, granule_time_tolerance=10, ncpus=1, + publisher_config=None ): """The NPP/VIIRS runner. Listens and triggers processing on RDR granules.""" @@ -609,10 +610,15 @@ def npp_rolling_runner( LOG.info("Will use %d CPUs when running CSPP instances" % ncpus) viirs_proc = ViirsSdrProcessor(ncpus, level1_home) + if publisher_config is None: + pubconf = {"name": "viirs_dr_runner", "port": 0} + else: + pubconf = yaml.safe_load(publisher_config) + LOG.debug("Subscribe topics = %s", str(subscribe_topics)) with posttroll.subscriber.Subscribe('', subscribe_topics, True) as subscr: - with Publish('viirs_dr_runner', 0) as publisher: + with Publish(**pubconf) as publisher: while True: viirs_proc.initialise() for msg in subscr.recv(timeout=300):