CC-4404: restart airtime-liquidsoap will interrupt the output stream and never resume until restart playout engine

-fixed
This commit is contained in:
Martin Konecny 2012-09-14 18:20:46 -04:00
parent 4ea3d86121
commit be80eeb5fd
6 changed files with 61 additions and 57 deletions

View File

@ -796,6 +796,7 @@ class ApiController extends Zend_Controller_Action
{ {
Logging::info("Notifying RabbitMQ to send message to pypo"); Logging::info("Notifying RabbitMQ to send message to pypo");
Application_Model_RabbitMq::SendMessageToPypo("reset_liquidsoap_bootstrap", array());
Application_Model_RabbitMq::PushSchedule(); Application_Model_RabbitMq::PushSchedule();
} }

View File

@ -3,14 +3,14 @@ require_once 'php-amqplib/amqp.inc';
class Application_Model_RabbitMq class Application_Model_RabbitMq
{ {
public static $doPush = FALSE; public static $doPush = false;
/** /**
* Sets a flag to push the schedule at the end of the request. * Sets a flag to push the schedule at the end of the request.
*/ */
public static function PushSchedule() public static function PushSchedule()
{ {
Application_Model_RabbitMq::$doPush = TRUE; self::$doPush = true;
} }
private static function sendMessage($exchange, $data) private static function sendMessage($exchange, $data)

View File

@ -399,7 +399,6 @@ dyn_out = output.icecast(%wav,
def set_dynamic_source_id(id) = def set_dynamic_source_id(id) =
current_dyn_id := id current_dyn_id := id
#"Done!"
string_of(!current_dyn_id) string_of(!current_dyn_id)
end end

View File

@ -19,7 +19,6 @@ queue = amplify(1., override="replay_gain", queue)
#live stream setup #live stream setup
set("harbor.bind_addr", "0.0.0.0") set("harbor.bind_addr", "0.0.0.0")
#TODO: Need to create a randomized password for every instance
current_dyn_id = ref '' current_dyn_id = ref ''
pypo_data = ref '0' pypo_data = ref '0'
@ -49,7 +48,10 @@ queue = map_metadata(update=false, append_title, queue)
queue = crossfade(queue) queue = crossfade(queue)
stream_queue = switch(id="stream_queue_switch", track_sensitive=false, transitions=[transition, transition], [({!webstream_enabled},web_stream), ({true}, queue)]) stream_queue = switch(id="stream_queue_switch", track_sensitive=false,
transitions=[transition, transition],
[({!webstream_enabled},web_stream),
({true}, queue)])
ignore(output.dummy(stream_queue, fallible=true)) ignore(output.dummy(stream_queue, fallible=true))
@ -113,31 +115,31 @@ ignore(output.dummy(default, fallible=true))
master_dj_enabled = ref false master_dj_enabled = ref false
live_dj_enabled = ref false live_dj_enabled = ref false
scheduled_play_enabled = ref false scheduled_play_enabled = ref false
def make_master_dj_available() def make_master_dj_available()
master_dj_enabled := true master_dj_enabled := true
end end
def make_master_dj_unavailable() def make_master_dj_unavailable()
master_dj_enabled := false master_dj_enabled := false
end end
def make_live_dj_available() def make_live_dj_available()
live_dj_enabled := true live_dj_enabled := true
end end
def make_live_dj_unavailable() def make_live_dj_unavailable()
live_dj_enabled := false live_dj_enabled := false
end end
def make_scheduled_play_available() def make_scheduled_play_available()
scheduled_play_enabled := true scheduled_play_enabled := true
just_switched := true just_switched := true
end end
def make_scheduled_play_unavailable() def make_scheduled_play_unavailable()
scheduled_play_enabled := false scheduled_play_enabled := false
end end
def update_source_status(sourcename, status) = def update_source_status(sourcename, status) =
@ -163,23 +165,23 @@ end
#auth function for live stream #auth function for live stream
def check_master_dj_client(user,password) = def check_master_dj_client(user,password) =
log("master connected") log("master connected")
#get the output of the php script #get the output of the php script
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}") ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --master #{user} #{password}")
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
ret = list.hd(ret) ret = list.hd(ret)
#return true to let the client transmit data, or false to tell harbor to decline #return true to let the client transmit data, or false to tell harbor to decline
ret == "True" ret == "True"
end end
def check_dj_client(user,password) = def check_dj_client(user,password) =
log("live dj connected") log("live dj connected")
#get the output of the php script #get the output of the php script
ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}") ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}")
#ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ...
hd = list.hd(ret) hd = list.hd(ret)
hd == "True" hd == "True"
end end
def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) = def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point, dj_harbor_input_port, dj_harbor_input_mount_point, s) =
@ -214,46 +216,48 @@ def append_dj_inputs(master_harbor_input_port, master_harbor_input_mount_point,
end end
end end
s = switch(id="default_switch", track_sensitive=false, transitions=[transition_default, transition], [({!scheduled_play_enabled},stream_queue),({true},default)]) s = switch(id="default_switch", track_sensitive=false,
s = append_dj_inputs(master_live_stream_port, master_live_stream_mp, dj_live_stream_port, dj_live_stream_mp, s) transitions=[transition_default, transition],
[({!scheduled_play_enabled}, stream_queue),({true},default)])
s = append_dj_inputs(master_live_stream_port, master_live_stream_mp,
dj_live_stream_port, dj_live_stream_mp, s)
# Attach a skip command to the source s: # Attach a skip command to the source s:
add_skip_command(s) add_skip_command(s)
server.register(namespace="streams", server.register(namespace="streams",
description="Stop Master DJ source.", description="Stop Master DJ source.",
usage="master_dj_stop", usage="master_dj_stop",
"master_dj_stop", "master_dj_stop",
fun (s) -> begin log("streams.master_dj_stop") make_master_dj_unavailable() "Done." end) fun (s) -> begin log("streams.master_dj_stop") make_master_dj_unavailable() "Done." end)
server.register(namespace="streams", server.register(namespace="streams",
description="Start Master DJ source.", description="Start Master DJ source.",
usage="master_dj_start", usage="master_dj_start",
"master_dj_start", "master_dj_start",
fun (s) -> begin log("streams.master_dj_start") make_master_dj_available() "Done." end) fun (s) -> begin log("streams.master_dj_start") make_master_dj_available() "Done." end)
server.register(namespace="streams", server.register(namespace="streams",
description="Stop Live DJ source.", description="Stop Live DJ source.",
usage="live_dj_stop", usage="live_dj_stop",
"live_dj_stop", "live_dj_stop",
fun (s) -> begin log("streams.live_dj_stop") make_live_dj_unavailable() "Done." end) fun (s) -> begin log("streams.live_dj_stop") make_live_dj_unavailable() "Done." end)
server.register(namespace="streams", server.register(namespace="streams",
description="Start Live DJ source.", description="Start Live DJ source.",
usage="live_dj_start", usage="live_dj_start",
"live_dj_start", "live_dj_start",
fun (s) -> begin log("streams.live_dj_start") make_live_dj_available() "Done." end) fun (s) -> begin log("streams.live_dj_start") make_live_dj_available() "Done." end)
server.register(namespace="streams", server.register(namespace="streams",
description="Stop Scheduled Play source.", description="Stop Scheduled Play source.",
usage="scheduled_play_stop", usage="scheduled_play_stop",
"scheduled_play_stop", "scheduled_play_stop",
fun (s) -> begin log("streams.scheduled_play_stop") make_scheduled_play_unavailable() "Done." end) fun (s) -> begin log("streams.scheduled_play_stop") make_scheduled_play_unavailable() "Done." end)
server.register(namespace="streams", server.register(namespace="streams",
description="Start Scheduled Play source.", description="Start Scheduled Play source.",
usage="scheduled_play_start", usage="scheduled_play_start",
"scheduled_play_start", "scheduled_play_start",
fun (s) -> begin log("streams.scheduled_play_start") make_scheduled_play_available() "Done." end) fun (s) -> begin log("streams.scheduled_play_start") make_scheduled_play_available() "Done." end)
if output_sound_device then if output_sound_device then
success = ref false success = ref false
log(output_sound_device_type) log(output_sound_device_type)

View File

@ -85,6 +85,8 @@ class PypoFetch(Thread):
if command == 'update_schedule': if command == 'update_schedule':
self.schedule_data = m['schedule'] self.schedule_data = m['schedule']
self.process_schedule(self.schedule_data) self.process_schedule(self.schedule_data)
elif command == 'reset_liquidsoap_bootstrap':
self.set_bootstrap_variables()
elif command == 'update_stream_setting': elif command == 'update_stream_setting':
self.logger.info("Updating stream setting...") self.logger.info("Updating stream setting...")
self.regenerate_liquidsoap_conf(m['setting']) self.regenerate_liquidsoap_conf(m['setting'])
@ -173,7 +175,7 @@ class PypoFetch(Thread):
def set_bootstrap_variables(self): def set_bootstrap_variables(self):
self.logger.debug('Getting information needed on bootstrap from Airtime') self.logger.debug('Getting information needed on bootstrap from Airtime')
info = self.api_client.get_bootstrap_info() info = self.api_client.get_bootstrap_info()
if info == None: if info is None:
self.logger.error('Unable to get bootstrap info.. Exiting pypo...') self.logger.error('Unable to get bootstrap info.. Exiting pypo...')
sys.exit(1) sys.exit(1)
else: else:

View File

@ -473,8 +473,6 @@ class PypoPush(Thread):
msg = 'streams.scheduled_play_start\n' msg = 'streams.scheduled_play_start\n'
tn.write(msg) tn.write(msg)
msg = 'dynamic_source.output_start\n' msg = 'dynamic_source.output_start\n'
self.logger.debug(msg) self.logger.debug(msg)
tn.write(msg) tn.write(msg)