Skip to content
Snippets Groups Projects
Commit 07fb25d0 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #7508: Moved process_command_queue to its own function

parent 4c3ada95
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,32 @@ class RouterConfig(SafeConfigParser): ...@@ -116,6 +116,32 @@ class RouterConfig(SafeConfigParser):
def destinations(self, source): def destinations(self, source):
return [field.strip() for field in self.get('multicast', source).split(',')] return [field.strip() for field in self.get('multicast', source).split(',')]
def process_command_queue(command_queue):
"""
Listen on the given queue, and process the received commands.
Supported commands:
stop - Do a graceful shutdown of this service
"""
log("INFO","[main] Listening for commands on %s" % (command_queue,))
cmdq = msgbus.FromBus(command_queue, "create: always, delete: always")
while True:
msg = cmdq.get(1.0)
if msg is None:
continue
command = msg.raw_content()
log("INFO","[main] Received command: %s" % (command,))
cmdq.ack(msg)
if command == "stop":
break
if __name__ == "__main__": if __name__ == "__main__":
""" """
Apply the routing specified in router.conf and router.conf.`hostname`; Apply the routing specified in router.conf and router.conf.`hostname`;
...@@ -156,23 +182,7 @@ if __name__ == "__main__": ...@@ -156,23 +182,7 @@ if __name__ == "__main__":
log("INFO","[main] Running %s threads" % (len(threadlist),)) log("INFO","[main] Running %s threads" % (len(threadlist),))
# Listen for commands on a special queue # Listen for commands on a special queue
command_queue = "messagerouter.command" process_command_queue("messagerouter.command")
log("INFO","[main] Listening for commands on %s" % (command_queue,))
cmdq = msgbus.FromBus(command_queue, "create: always, delete: always")
while True:
msg = cmdq.get(1.0)
if msg is None:
continue
command = msg.raw_content()
log("INFO","[main] Received command: %s" % (command,))
cmdq.ack(msg)
if command == "stop":
break
log("INFO","[main] Shutting down") log("INFO","[main] Shutting down")
......
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