Skip to content
Snippets Groups Projects
Commit ee9a0796 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-699: wrap event_listener in a janitor to auto cleanup the designed listening queue upon exit.

this tool is only meant for live listening, not for historic logs
parent 7be40703
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
from lofar.common.util import humanreadablesize from lofar.common.util import humanreadablesize
from lofar.messaging.messagebus import BusListener, AbstractMessageHandler from lofar.messaging.messagebus import BusListener, AbstractMessageHandler, BusListenerJanitor
from lofar.lta.ingest.common.config import INGEST_NOTIFICATION_PREFIX from lofar.lta.ingest.common.config import INGEST_NOTIFICATION_PREFIX
from lofar.messaging.messagebus import DEFAULT_BROKER, DEFAULT_BUSNAME from lofar.messaging.messagebus import DEFAULT_BROKER, DEFAULT_BUSNAME
from lofar.messaging.messages import EventMessage from lofar.messaging.messages import EventMessage
...@@ -191,15 +191,19 @@ def main(): ...@@ -191,15 +191,19 @@ def main():
# Check the invocation arguments # Check the invocation arguments
parser = OptionParser('%prog [options]', parser = OptionParser('%prog [options]',
description='run the ingest job monitor') description='run the ingest job monitor')
parser.add_option('-q', '--broker', dest='broker', type='string', default=DEFAULT_BROKER, help='Address of the message broker, default: %default') parser.add_option('-b', '--broker', dest='broker', type='string', default=DEFAULT_BROKER, help='Address of the message broker, default: %default')
parser.add_option('--exchange', dest='exchange', type='string', default=DEFAULT_BUSNAME, help='Name of the exchange on which the ingest notifications are published, default: %default') parser.add_option('-e', '--exchange', dest='exchange', type='string', default=DEFAULT_BUSNAME, help='Name of the exchange on which the ingest notifications are published, default: %default')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
level=logging.INFO, level=logging.INFO,
stream=sys.stdout) stream=sys.stdout)
with IngestEventMesssageBusListener(exchange=options.exchange, broker=options.broker): event_listener = IngestEventMesssageBusListener(exchange=options.exchange, broker=options.broker)
# wrap event_listener in a janitor to auto cleanup the designed listening queue upon exit.
# this tool is only meant for live listening, not for historic logs.
with BusListenerJanitor(event_listener):
waitForInterrupt() waitForInterrupt()
if __name__ == '__main__': if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment