CC-2419: Media monitor does not import files that already existed in /srv/airtime/stor

-problem where media-monitor froze on startup if rabbitmq
 wasn't running is fixed (now consistent with pypo)
This commit is contained in:
martin 2011-06-24 15:13:47 -04:00
parent 0a78605633
commit 10c7c0b5fd

View file

@ -27,6 +27,14 @@ class AirtimeNotifier(Notifier):
self.import_processes = {}
self.watched_folders = []
while not self.init_rabbit_mq():
logger.error("Error connecting to RabbitMQ Server. Trying again in few seconds")
time.sleep(5)
def init_rabbit_mq(self):
logger = logging.getLogger('fetch')
logger.info("Initializing RabbitMQ stuff")
try:
schedule_exchange = Exchange("airtime-media-monitor", "direct", durable=True, auto_delete=True)
schedule_queue = Queue("media-monitor", exchange=schedule_exchange, key="filesystem")
self.connection = BrokerConnection(self.config.cfg["rabbitmq_host"], self.config.cfg["rabbitmq_user"], self.config.cfg["rabbitmq_password"], "/")
@ -34,6 +42,11 @@ class AirtimeNotifier(Notifier):
consumer = Consumer(channel, schedule_queue)
consumer.register_callback(self.handle_message)
consumer.consume()
except Exception, e:
logger.error(e)
return False
return True
def handle_message(self, body, message):
# ACK the message to take it off the queue