CC-2750: Ability to query health status for pypo,

liquidsoap, media monitor, and recorder

-fixed rabbitmq not delivering messages
This commit is contained in:
martin 2011-09-13 14:56:24 -04:00
parent d942e476c6
commit 2c2bb86698
4 changed files with 32 additions and 22 deletions

View File

@ -7,6 +7,7 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract
if (RabbitMq::$doPush) { if (RabbitMq::$doPush) {
$md = array('schedule' => Schedule::GetScheduledPlaylists()); $md = array('schedule' => Schedule::GetScheduledPlaylists());
RabbitMq::SendMessageToPypo("update_schedule", $md); RabbitMq::SendMessageToPypo("update_schedule", $md);
RabbitMq::SendMessageToShowRecorder("update_schedule");
} }
} }
} }

View File

@ -34,8 +34,6 @@ class RabbitMq
$channel->basic_publish($msg, $EXCHANGE); $channel->basic_publish($msg, $EXCHANGE);
$channel->close(); $channel->close();
$conn->close(); $conn->close();
self::SendMessageToShowRecorder("update_schedule");
} }
public static function SendMessageToMediaMonitor($event_type, $md) public static function SendMessageToMediaMonitor($event_type, $md)

View File

@ -4,6 +4,9 @@ class Application_Model_Systemstatus
{ {
public static function GetPypoStatus(){ public static function GetPypoStatus(){
RabbitMq::SendMessageToPypo("get_status", array());
return array( return array(
"process_id"=>500, "process_id"=>500,
"uptime_seconds"=>3600 "uptime_seconds"=>3600

View File

@ -20,6 +20,7 @@ import filecmp
# For RabbitMQ # For RabbitMQ
from kombu.connection import BrokerConnection from kombu.connection import BrokerConnection
from kombu.messaging import Exchange, Queue, Consumer, Producer from kombu.messaging import Exchange, Queue, Consumer, Producer
from kombu.exceptions import MessageStateError
from api_clients import api_client from api_clients import api_client
@ -72,26 +73,33 @@ class PypoFetch(Thread):
Hopefully there is a better way to do this. Hopefully there is a better way to do this.
""" """
def handle_message(self, body, message): def handle_message(self, body, message):
logger = logging.getLogger('fetch') try:
logger.info("Received event from RabbitMQ: " + message.body) logger = logging.getLogger('fetch')
logger.info("Received event from RabbitMQ: " + message.body)
m = json.loads(message.body)
command = m['event_type']
logger.info("Handling command: " + command)
m = json.loads(message.body) if command == 'update_schedule':
command = m['event_type'] self.schedule_data = m['schedule']
logger.info("Handling command: " + command) self.process_schedule(self.schedule_data, "scheduler", False)
elif command == 'update_stream_setting':
if command == 'update_schedule': logger.info("Updating stream setting...")
self.schedule_data = m['schedule'] self.regenerateLiquidsoapConf(m['setting'])
self.process_schedule(self.schedule_data, "scheduler", False) elif command == 'cancel_current_show':
elif command == 'update_stream_setting': logger.info("Cancel current show command received...")
logger.info("Updating stream setting...") self.stop_current_show()
self.regenerateLiquidsoapConf(m['setting']) elif command == 'get_status':
elif command == 'cancel_current_show': self.get_status()
logger.info("Cancel current show command received...") except Exception, e:
self.stop_current_show() logger.error("Exception in handling RabbitMQ message: %s", e)
elif command == 'get_status': finally:
self.get_status() # ACK the message to take it off the queue
# ACK the message to take it off the queue try:
message.ack() message.ack()
except MessageStateError, m:
logger.error("Message ACK error: %s", m);
def get_status(self): def get_status(self):
logger = logging.getLogger('fetch') logger = logging.getLogger('fetch')