CC-2784: Stopping rabbitmq-server causes pypo CPU usage to increase dramatically
-fixed
This commit is contained in:
parent
b2db168a10
commit
6dab211a12
|
@ -17,13 +17,13 @@ DAEMON=/usr/lib/airtime/media-monitor/airtime-media-monitor
|
||||||
PIDFILE=/var/run/airtime-media-monitor.pid
|
PIDFILE=/var/run/airtime-media-monitor.pid
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
#monit monitor airtime-media-monitor >/dev/null 2>&1
|
monit monitor airtime-media-monitor >/dev/null 2>&1
|
||||||
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
|
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE --startas $DAEMON
|
||||||
}
|
}
|
||||||
|
|
||||||
stop () {
|
stop () {
|
||||||
# Send TERM after 5 seconds, wait at most 30 seconds.
|
# Send TERM after 5 seconds, wait at most 30 seconds.
|
||||||
#monit unmonitor airtime-media-monitor >/dev/null 2>&1
|
monit unmonitor airtime-media-monitor >/dev/null 2>&1
|
||||||
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
|
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
|
||||||
rm -f $PIDFILE
|
rm -f $PIDFILE
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,9 @@ import socket
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
import pyinotify
|
import pyinotify
|
||||||
from pyinotify import ProcessEvent
|
from pyinotify import ProcessEvent
|
||||||
|
|
||||||
# For RabbitMQ
|
|
||||||
from kombu.connection import BrokerConnection
|
|
||||||
from kombu.messaging import Exchange, Queue, Consumer, Producer
|
|
||||||
|
|
||||||
from airtimemetadata import AirtimeMetadata
|
from airtimemetadata import AirtimeMetadata
|
||||||
from airtimefilemonitor.mediaconfig import AirtimeMediaConfig
|
from airtimefilemonitor.mediaconfig import AirtimeMediaConfig
|
||||||
|
|
||||||
|
@ -186,8 +181,10 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.mmc.touch_index_file()
|
self.mmc.touch_index_file()
|
||||||
|
|
||||||
self.file_events = []
|
self.file_events = []
|
||||||
#yeild to workder thread
|
|
||||||
|
#yield to worker thread
|
||||||
time.sleep(0)
|
time.sleep(0)
|
||||||
|
|
||||||
#use items() because we are going to be modifying this
|
#use items() because we are going to be modifying this
|
||||||
#dictionary while iterating over it.
|
#dictionary while iterating over it.
|
||||||
for k, pair in self.cookies_IN_MOVED_FROM.items():
|
for k, pair in self.cookies_IN_MOVED_FROM.items():
|
||||||
|
@ -206,7 +203,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.handle_removed_file(False, event.pathname)
|
self.handle_removed_file(False, event.pathname)
|
||||||
|
|
||||||
|
|
||||||
#check for any events recieved from Airtime.
|
#check for any events received from Airtime.
|
||||||
try:
|
try:
|
||||||
notifier.connection.drain_events(timeout=0.1)
|
notifier.connection.drain_events(timeout=0.1)
|
||||||
#avoid logging a bunch of timeout messages.
|
#avoid logging a bunch of timeout messages.
|
||||||
|
@ -214,4 +211,5 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
pass
|
pass
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.info("%s", e)
|
self.logger.info("%s", e)
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
with pidfile "/var/run/airtime-liquidsoap.pid"
|
with pidfile "/var/run/airtime-liquidsoap.pid"
|
||||||
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
|
start program = "/etc/init.d/airtime-playout start" with timeout 10 seconds
|
||||||
stop program = "/etc/init.d/airtime-playout stop"
|
stop program = "/etc/init.d/airtime-playout stop"
|
||||||
# check process airtime-media-monitor
|
check process airtime-media-monitor
|
||||||
# with pidfile "/var/run/airtime-media-monitor.pid"
|
with pidfile "/var/run/airtime-media-monitor.pid"
|
||||||
# start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
|
start program = "/etc/init.d/airtime-media-monitor start" with timeout 10 seconds
|
||||||
# stop program = "/etc/init.d/airtime-media-monitor stop"
|
stop program = "/etc/init.d/airtime-media-monitor stop"
|
||||||
check process airtime-show-recorder
|
check process airtime-show-recorder
|
||||||
with pidfile "/var/run/airtime-show-recorder.pid"
|
with pidfile "/var/run/airtime-show-recorder.pid"
|
||||||
start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds
|
start program = "/etc/init.d/airtime-show-recorder start" with timeout 10 seconds
|
||||||
|
|
|
@ -9,6 +9,7 @@ import string
|
||||||
import json
|
import json
|
||||||
import telnetlib
|
import telnetlib
|
||||||
import math
|
import math
|
||||||
|
import socket
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -351,12 +352,7 @@ class PypoFetch(Thread):
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|
||||||
|
|
||||||
"""
|
def main(self):
|
||||||
Main loop of the thread:
|
|
||||||
Wait for schedule updates from RabbitMQ, but in case there arent any,
|
|
||||||
poll the server to get the upcoming schedule.
|
|
||||||
"""
|
|
||||||
def run(self):
|
|
||||||
logger = logging.getLogger('fetch')
|
logger = logging.getLogger('fetch')
|
||||||
|
|
||||||
while not self.init_rabbit_mq():
|
while not self.init_rabbit_mq():
|
||||||
|
@ -384,12 +380,31 @@ class PypoFetch(Thread):
|
||||||
# Hooray for globals!
|
# Hooray for globals!
|
||||||
schedule_data = SCHEDULE_PUSH_MSG
|
schedule_data = SCHEDULE_PUSH_MSG
|
||||||
status = 1
|
status = 1
|
||||||
except:
|
except socket.timeout, se:
|
||||||
# We didnt get a message for a while, so poll the server
|
# We didnt get a message for a while, so poll the server
|
||||||
# to get an updated schedule.
|
# to get an updated schedule.
|
||||||
status, schedule_data = self.api_client.get_schedule()
|
status, schedule_data = self.api_client.get_schedule()
|
||||||
|
except Exception, e:
|
||||||
|
"""
|
||||||
|
This Generic exception is thrown whenever the RabbitMQ
|
||||||
|
Service is stopped. In this case let's check every few
|
||||||
|
seconds to see if it has come back up
|
||||||
|
"""
|
||||||
|
logger.info("Unknown exception")
|
||||||
|
return
|
||||||
|
|
||||||
|
#return based on the exception
|
||||||
|
|
||||||
if status == 1:
|
if status == 1:
|
||||||
self.process_schedule(schedule_data, "scheduler", False)
|
self.process_schedule(schedule_data, "scheduler", False)
|
||||||
loops += 1
|
loops += 1
|
||||||
|
|
||||||
|
"""
|
||||||
|
Main loop of the thread:
|
||||||
|
Wait for schedule updates from RabbitMQ, but in case there arent any,
|
||||||
|
poll the server to get the upcoming schedule.
|
||||||
|
"""
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
self.main()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
import socket
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
|
||||||
|
@ -289,10 +290,12 @@ class CommandListener(Thread):
|
||||||
try:
|
try:
|
||||||
# block until 5 seconds before the next show start
|
# block until 5 seconds before the next show start
|
||||||
self.connection.drain_events(timeout=self.time_till_next_show)
|
self.connection.drain_events(timeout=self.time_till_next_show)
|
||||||
except Exception, e:
|
except socket.timeout, s:
|
||||||
self.logger.info(e)
|
self.logger.info(s)
|
||||||
# start recording
|
# start recording
|
||||||
self.start_record()
|
self.start_record()
|
||||||
|
except Exception, e:
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
loops += 1
|
loops += 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue