Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Naomi Aro 2011-12-27 14:34:27 -08:00
commit 905775552d
27 changed files with 221 additions and 149 deletions

View File

@ -8,7 +8,9 @@
* that the user can customize these.
*/
$ini = parse_ini_file('/etc/airtime/airtime.conf', true);
$configFile = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
$ini = parse_ini_file($configFile, true);
$dbhost = $ini['database']['host'];
$dbname = $ini['database']['dbname'];

View File

@ -23,7 +23,9 @@ $CC_CONFIG = array(
'phingPath' => dirname(__FILE__).'/../../library/phing'
);
Config::loadConfig("/etc/airtime/airtime.conf");
$configFile = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf";
Config::loadConfig($configFile);
// Add database table names
$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist';

View File

@ -23,8 +23,7 @@ class ApiController extends Zend_Controller_Action
->addActionContext('get-stream-setting', 'json')
->addActionContext('status', 'json')
->addActionContext('register-component', 'json')
->addActionContext('update-liquidsoap-error', 'json')
->addActionContext('update-liquidsoap-connection', 'json')
->addActionContext('update-liquidsoap-status', 'json')
->addActionContext('library-init', 'json')
->addActionContext('live-chat', 'json')
->initContext();
@ -780,22 +779,14 @@ class ApiController extends Zend_Controller_Action
Application_Model_ServiceRegister::Register($component, $remoteAddr);
}
public function updateLiquidsoapErrorAction(){
public function updateLiquidsoapStatusAction(){
$request = $this->getRequest();
$error_msg = $request->getParam('error_msg');
$msg = $request->getParam('msg');
$stream_id = $request->getParam('stream_id');
$boot_time = $request->getParam('boot_time');
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg, $boot_time);
}
public function updateLiquidsoapConnectionAction(){
$request = $this->getRequest();
$stream_id = $request->getParam('stream_id');
$boot_time = $request->getParam('boot_time');
// setting error_msg as "" when there is no error_msg
Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK", $boot_time);
Application_Model_StreamSetting::setLiquidsoapError($stream_id, $msg, $boot_time);
}
/**

View File

@ -133,6 +133,7 @@ class PreferenceController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/meioMask/jquery.meio.mask.js','text/javascript');
// get current settings
$temp = Application_Model_StreamSetting::getStreamSetting();

View File

@ -7,7 +7,9 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract
if (Application_Model_RabbitMq::$doPush) {
$md = array('schedule' => Application_Model_Schedule::GetScheduledPlaylists());
Application_Model_RabbitMq::SendMessageToPypo("update_schedule", $md);
Application_Model_RabbitMq::SendMessageToShowRecorder("update_schedule");
if (!isset($_SERVER['AIRTIME_SRV'])){
Application_Model_RabbitMq::SendMessageToShowRecorder("update_schedule");
}
}
}
}

View File

@ -68,8 +68,10 @@ class Application_Form_StreamSetting extends Zend_Form
}
public function isValid($data){
$this->populate(array("output_sound_device"=>$data['output_sound_device'], "icecast_vorbis_metadata"=>$data['icecast_vorbis_metadata'],
if($data['output_sound_device']){
$this->populate(array("output_sound_device"=>$data['output_sound_device'], "icecast_vorbis_metadata"=>$data['icecast_vorbis_metadata'],
"output_sound_device_type"=>$data['output_sound_device_type'], "streamFormat"=>$data['streamFormat']));
}
return true;
}
}

View File

@ -83,10 +83,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$host = new Zend_Form_Element_Text('host');
$host->setLabel("Server")
->setValue(isset($setting[$prefix.'_host'])?$setting[$prefix.'_host']:"")
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z-_.]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
$host->setAttrib("disabled", "disabled");
}
$host->setAttrib('alt', 'domain');
$this->addElement($host);
$port = new Zend_Form_Element_Text('port');
@ -103,10 +106,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$pass = new Zend_Form_Element_Text('pass');
$pass->setLabel("Password")
->setValue(isset($setting[$prefix.'_pass'])?$setting[$prefix.'_pass']:"")
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
$pass->setAttrib("disabled", "disabled");
}
$pass->setAttrib('alt', 'regular_text');
$this->addElement($pass);
$genre = new Zend_Form_Element_Text('genre');
@ -121,10 +127,13 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$url = new Zend_Form_Element_Text('url');
$url->setLabel("URL")
->setValue(isset($setting[$prefix.'_url'])?$setting[$prefix.'_url']:"")
->setValidators(array(
array('regex', false, array('/^[0-9a-zA-Z\-_.:\/]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
$url->setAttrib("disabled", "disabled");
}
$url->setAttrib('alt', 'url');
$this->addElement($url);
$description = new Zend_Form_Element_Text('description');
@ -139,19 +148,25 @@ class Application_Form_StreamSettingSubForm extends Zend_Form_SubForm{
$mount = new Zend_Form_Element_Text('mount');
$mount->setLabel("Mount Point")
->setValue(isset($setting[$prefix.'_mount'])?$setting[$prefix.'_mount']:"")
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
$mount->setAttrib("disabled", "disabled");
}
$mount->setAttrib('alt', 'regular_text');
$this->addElement($mount);
$user = new Zend_Form_Element_Text('user');
$user->setLabel("Username")
->setValue(isset($setting[$prefix.'_user'])?$setting[$prefix.'_user']:"")
->setValidators(array(
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
->setDecorators(array('ViewHelper'));
if($disable_all){
$user->setAttrib("disabled", "disabled");
}
$user->setAttrib('alt', 'regular_text');
$this->addElement($user);
$liquidsopa_error_msg = '<div class="stream-status status-info"><h3>Getting information from the server...</h3></div>';

View File

@ -409,11 +409,13 @@ class Application_Model_StoredFile {
* @return string
*/
public function getFilePath()
{
{
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
$directory = $music_dir->getDirectory();
$filepath = $this->_file->getDbFilepath();
return $music_dir->getDirectory().$filepath;
return $directory.$filepath;
}
/**
@ -877,8 +879,13 @@ class Application_Model_StoredFile {
$audio_stor = $stor . DIRECTORY_SEPARATOR . $fileName;
$r = @copy($audio_file, $audio_stor);
$r = @unlink($audio_file);
Logging::log("copyFileToStor: moving file $audio_file to $audio_stor");
//Martin K.: changed to rename: Much less load + quicker since this is an atomic operation
$r = @rename($audio_file, $audio_stor);
//$r = @copy($audio_file, $audio_stor);
//$r = @unlink($audio_file);
}
public static function getFileCount()

View File

@ -174,5 +174,18 @@ $(document).ready(function() {
showErrorSections()
setInterval('checkLiquidsoapStatus()', 1000)
$.mask.rules = {
'@': /[^ &<>]/,
'u': /[0-9a-zA-Z-_.:/]/,
'd': /[0-9a-zA-Z-_.]/
}
// add masking on the fields that don't allow special chars
$.mask.masks = $.extend($.mask.masks,{
regular_text:{ mask: '@', type:'repeat', 'maxLength': 256, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),:/]'},
url:{ mask: 'u', type:'repeat', 'maxLength': 261, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),]'},
domain:{ mask: 'd', type:'repeat', 'maxLength': 261, selectCharsOnFocus: false, autoTab: false, fixedChars : '[(),:/]'}
})
$('input:text').setMask()
});

View File

@ -17,16 +17,17 @@ fi
showhelp () {
echo "Usage: airtime-install [options]
--help|-h Displays usage information.
--overwrite|-o Overwrite any existing config files.
--preserve|-p Keep any existing config files.
--no-db|-n Turn off database install.
--reinstall|-r Force a fresh install of this Airtime Version
--media-monitor|-m Install only media-monitor
--pypo|-p Install only pypo and liquidsoap
--show-recorder|-s Install only show-recorder
--web|-w Install only files for web-server
--liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading"
--help|-h Displays usage information.
--overwrite|-o Overwrite any existing config files.
--preserve|-p Keep any existing config files.
--no-db|-n Turn off database install.
--reinstall|-r Force a fresh install of this Airtime Version
--media-monitor|-m Install only media-monitor
--pypo|-p Install only pypo and liquidsoap
--show-recorder|-s Install only show-recorder
--web|-w Install only files for web-server
--liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading
--disable-auto-start-services|-d Disable auto-starting Airtime services"
}
overwrite="f"
@ -38,8 +39,9 @@ pypo="f"
showrecorder="f"
web="f"
liquidsoap_keep_alive="f"
disable_auto_start_services="f"
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web,liquidsoap-keep-alive "hopnrmyswl" "$@")
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web,liquidsoap-keep-alive,disable-auto-start-services "hopnrmyswld" "$@")
while [ $# -gt 0 ]
do
case "$1" in
@ -53,6 +55,7 @@ do
(-s|--show-recorder) showrecorder="t";;
(-w|--web) web="t";;
(-l|--liquidsoap-keep-alive) liquidsoap_keep_alive="t";;
(-d|--disable-auto-start-services) disable_auto_start_services="t";;
(--) shift; break;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
@ -107,6 +110,7 @@ export nodb
export overwrite
export preserve
export liquidsoap_keep_alive
export disable_auto_start_services
set +e
test "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t"

View File

@ -53,15 +53,17 @@ sleep 1
set +e
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
fi
if [ "$showrecorder" = "t" ]; then
monit monitor airtime-show-recorder
if [ "$disable_auto_start_services" = "f" ]; then
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
fi
if [ "$showrecorder" = "t" ]; then
monit monitor airtime-show-recorder
fi
fi
monit monitor rabbitmq-server

View File

@ -92,11 +92,8 @@ generate_range_url = 'generate_range_dp.php'
# URL to tell Airtime we want to get stream setting
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
#URL to update liquidsoap error msg
update_liquidsoap_error = 'update-liquidsoap-error/format/json/api_key/%%api_key%%/error_msg/%%error_msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to update liquidsoap connection
update_liquidsoap_connection = 'update-liquidsoap-connection/format/json/api_key/%%api_key%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to update liquidsoap status
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
##############
# OBP config #

View File

@ -92,11 +92,8 @@ generate_range_url = 'generate_range_dp.php'
# URL to tell Airtime we want to get stream setting
get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/'
#URL to update liquidsoap error msg
update_liquidsoap_error = 'update-liquidsoap-error/format/json/api_key/%%api_key%%/error_msg/%%error_msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to update liquidsoap connection
update_liquidsoap_connection = 'update-liquidsoap-connection/format/json/api_key/%%api_key%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
#URL to update liquidsoap status
update_liquidsoap_status = 'update-liquidsoap-status/format/json/api_key/%%api_key%%/msg/%%msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%'
##############
# OBP config #

View File

@ -571,29 +571,15 @@ class AirTimeApiClient(ApiClientInterface):
except Exception, e:
logger.error("Exception: %s", e)
def notify_liquidsoap_error(self, error_msg, stream_id, time):
def notify_liquidsoap_status(self, msg, stream_id, time):
logger = logging.getLogger()
try:
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_error"])
url = url.replace("%%api_key%%", self.config["api_key"])
error_msg = error_msg.replace('/', ' ')
encoded_msg = urllib.quote(error_msg, '')
url = url.replace("%%error_msg%%", encoded_msg)
url = url.replace("%%stream_id%%", stream_id)
url = url.replace("%%boot_time%%", time)
logger.debug(url)
req = urllib2.Request(url)
response = urllib2.urlopen(req).read()
except Exception, e:
logger.error("Exception: %s", e)
def notify_liquidsoap_connection(self, stream_id, time):
logger = logging.getLogger()
try:
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_connection"])
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_status"])
url = url.replace("%%api_key%%", self.config["api_key"])
msg = msg.replace('/', ' ')
encoded_msg = urllib.quote(msg, '')
url = url.replace("%%msg%%", encoded_msg)
url = url.replace("%%stream_id%%", stream_id)
url = url.replace("%%boot_time%%", time)
logger.debug(url)

View File

@ -42,8 +42,9 @@ try:
sys.exit(1)
#copy monit files
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
if os.environ["disable_auto_start_services"] == "f":
shutil.copy('%s/../monit-airtime-media-monitor.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create log dir
create_dir(config['log_dir'])

View File

@ -6,15 +6,17 @@ if os.geteuid() != 0:
sys.exit(1)
try:
#update-rc.d init script
p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
if os.environ["disable_auto_start_services"] == "f":
#update-rc.d init script
p = Popen("update-rc.d airtime-media-monitor defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#Start media-monitor daemon
print "* Waiting for media-monitor processes to start..."
p = Popen("/etc/init.d/airtime-media-monitor stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-media-monitor start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#Start media-monitor daemon
print "* Waiting for media-monitor processes to start..."
p = Popen("/etc/init.d/airtime-media-monitor stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-media-monitor start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
except Exception, e:
print e

View File

@ -3,8 +3,3 @@
set httpd port 2812
allow admin:monit
check process rabbitmq-server
with pidfile "/var/run/rabbitmq.pid"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; /usr/lib/airtime/utils/rabbitmq-update-pid.sh'"
stop program = "/etc/init.d/rabbitmq-server stop"

View File

@ -1,11 +1,7 @@
set daemon 10 # Poll at 5 second intervals
#set logfile syslog facility log_daemon
set logfile /var/log/monit.log
set httpd port 2812
allow admin:monit
check process rabbitmq-server
with pidfile "/var/run/rabbitmq.pid"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids > /var/run/rabbitmq.pid'"
start program = "/bin/bash -c '/etc/init.d/rabbitmq-server start; /usr/lib/airtime/utils/rabbitmq-update-pid.sh'"
stop program = "/etc/init.d/rabbitmq-server stop"

View File

@ -42,9 +42,11 @@ try:
sys.exit(1)
#copy monit files
shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../monit-airtime-liquidsoap.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../../monit/monit-airtime-rabbitmq-server.cfg'%current_script_dir, '/etc/monit/conf.d/')
if os.environ["disable_auto_start_services"] == "f":
shutil.copy('%s/../monit-airtime-liquidsoap.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../monit-airtime-playout.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create pypo log dir
create_dir(config['pypo_log_dir'])

View File

@ -87,10 +87,6 @@ try:
print "Unsupported system architecture."
sys.exit(1)
#initialize init.d scripts
p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#generate liquidsoap config file
#access the DB and generate liquidsoap.cfg under /etc/airtime/
ac = api_client.api_client_factory(config)
@ -101,18 +97,23 @@ try:
else:
print "Unable to connect to the Airtime server."
#restart airtime-playout
print "* Waiting for pypo processes to start..."
if os.environ["liquidsoap_keep_alive"] == "f":
print " * Restarting any previous Liquidsoap instances"
p = Popen("/etc/init.d/airtime-playout stop", shell=True)
if os.environ["disable_auto_start_services"] == "f":
#initialize init.d scripts
p = Popen("update-rc.d airtime-playout defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
else:
print " * Keeping any previous Liquidsoap instances running"
p = Popen("/etc/init.d/airtime-playout pypo-stop", shell=True)
#restart airtime-playout
print "* Waiting for pypo processes to start..."
if os.environ["liquidsoap_keep_alive"] == "f":
print " * Restarting any previous Liquidsoap instances"
p = Popen("/etc/init.d/airtime-playout stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
else:
print " * Keeping any previous Liquidsoap instances running"
p = Popen("/etc/init.d/airtime-playout pypo-stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-playout start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-playout start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
except Exception, e:
print e

View File

@ -37,15 +37,17 @@ def to_live(old,new) =
end
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream) =
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream, connected) =
def on_error(msg)
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{time}")
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{time}")
connected := "false"
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{!time}")
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{!time}")
5.
end
def on_connect()
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{time}")
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{time}")
connected := "true"
system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{!time}")
log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{!time}")
end
if output_type == "icecast" then
user_ref = ref user
@ -136,7 +138,8 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
if url == "" then
url_ref := "N/A"
end
output.shoutcast = output.shoutcast(host = host,
output.shoutcast = output.shoutcast(id = "shoutcast_stream_#{stream}",
host = host,
port = port,
password = pass,
fallible = true,

View File

@ -6,7 +6,7 @@ set("log.stdout", true)
set("server.telnet", true)
set("server.telnet.port", 1234)
time = gettimeofday()
time = ref string_of(gettimeofday())
queue = audio_to_stereo(request.queue(id="queue", length=0.5))
queue = cue_cut(queue)
@ -17,6 +17,13 @@ stream_metadata_type = ref 0
station_name = ref ''
show_name = ref ''
s1_connected = ref ''
s2_connected = ref ''
s3_connected = ref ''
s1_namespace = ref ''
s2_namespace = ref ''
s3_namespace = ref ''
%include "ls_lib.liq"
server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
@ -24,6 +31,8 @@ server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_str
server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end)
server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s end)
server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end)
server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end)
server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end)
default = amplify(0.00001, noise())
@ -100,19 +109,34 @@ if output_sound_device then
end
if s1_enable == true then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass, s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1")
if s1_output == 'shoutcast' then
s1_namespace := "shoutcast_stream_1"
else
s1_namespace := s1_mount
end
server.register(namespace=!s1_namespace, "connected", fun (s) -> begin !s1_connected end)
output_to(s1_output, s1_type, s1_bitrate, s1_host, s1_port, s1_pass, s1_mount, s1_url, s1_description, s1_genre, s1_user, s, "1", s1_connected)
end
if s2_enable == true then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass, s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2")
if s2_output == 'shoutcast' then
s2_namespace := "shoutcast_stream_2"
else
s2_namespace := s2_mount
end
server.register(namespace=!s2_namespace, "connected", fun (s) -> begin !s2_connected end)
output_to(s2_output, s2_type, s2_bitrate, s2_host, s2_port, s2_pass, s2_mount, s2_url, s2_description, s2_genre, s2_user, s, "2", s2_connected)
end
if s3_enable == true then
#output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, s)
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3")
if s3_output == 'shoutcast' then
s3_namespace := "shoutcast_stream_3"
else
s3_namespace := s3_mount
end
server.register(namespace=!s3_namespace, "connected", fun (s) -> begin !s3_connected end)
output_to(s3_output, s3_type, s3_bitrate, s3_host, s3_port, s3_pass, s3_mount, s3_url, s3_description, s3_genre, s3_user, s, "3", s3_connected)
end
ignore(output.dummy(blank()))

View File

@ -82,24 +82,14 @@ class Notify:
logger.debug("Response: "+json.dumps(response))
# @pram time: time that LS started
def notify_liquidsoap_error(self, error_msg, stream_id, time):
def notify_liquidsoap_status(self, msg, stream_id, time):
logger = logging.getLogger()
logger.debug('#################################################')
logger.debug('# Calling server to update liquidsoap error #')
logger.debug('# Calling server to update liquidsoap status #')
logger.debug('#################################################')
logger.debug('error msg = '+ str(error_msg))
response = self.api_client.notify_liquidsoap_error(error_msg, stream_id, time)
logger.debug("Response: "+json.dumps(response))
# @pram time: time that LS started
def notify_liquidsoap_connection(self, stream_id, time):
logger = logging.getLogger()
logger.debug('#################################################')
logger.debug('# Calling server to update liquidsoap connection#')
logger.debug('#################################################')
response = self.api_client.notify_liquidsoap_connection(stream_id, time)
logger.debug('msg = '+ str(msg))
response = self.api_client.notify_liquidsoap_status(msg, stream_id, time)
logger.debug("Response: "+json.dumps(response))
if __name__ == '__main__':
@ -115,13 +105,13 @@ if __name__ == '__main__':
if options.error and options.stream_id:
try:
n = Notify()
n.notify_liquidsoap_error(options.error, options.stream_id, options.time)
n.notify_liquidsoap_status(options.error, options.stream_id, options.time)
except Exception, e:
print e
elif options.connect and options.stream_id:
try:
n = Notify()
n.notify_liquidsoap_connection(options.stream_id, options.time)
n.notify_liquidsoap_status("OK", options.stream_id, options.time)
except Exception, e:
print e
else:

View File

@ -216,6 +216,41 @@ class PypoFetch(Thread):
self.process_schedule(self.schedule_data, "scheduler", False)
else:
logger.info("No change detected in setting...")
self.update_liquidsoap_connection_status()
"""
updates the status of liquidsoap connection to the streaming server
This fucntion updates the bootup time variable in liquidsoap script
"""
def update_liquidsoap_connection_status(self):
logger = logging.getLogger('fetch')
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
# update the boot up time of liquidsoap. Since liquidsoap is not restarting,
# we are manually adjusting the bootup time variable so the status msg will get
# updated.
current_time = time.time()
boot_up_time_command = "vars.bootup_time "+str(current_time)+"\n"
tn.write(boot_up_time_command)
tn.write("streams.connection_status\n")
tn.write('exit\n')
output = tn.read_all()
output_list = output.split("\r\n")
stream_info = output_list[2]
# streamin info is in the form of:
# eg. s1:true,2:true,3:false
streams = stream_info.split(",")
logger.info(streams)
fake_time = current_time + 1
for s in streams:
info = s.split(':')
stream_id = info[0]
status = info[1]
if(status == "true"):
self.api_client.notify_liquidsoap_status("OK", stream_id, str(fake_time))
def set_export_source(self, export_source):
logger = logging.getLogger('fetch')

View File

@ -41,10 +41,11 @@ try:
print 'Error loading config file: ', e
sys.exit(1)
#copy monit files
shutil.copy('%s/../monit-airtime-show-recorder.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
if os.environ["disable_auto_start_services"] == "f":
shutil.copy('%s/../monit-airtime-show-recorder.cfg'%current_script_dir, '/etc/monit/conf.d/')
#create temporary media-storage directory
#print "Creating temporary media storage directory"

View File

@ -7,15 +7,16 @@ if os.geteuid() != 0:
sys.exit(1)
try:
#register init.d script
p = Popen("update-rc.d airtime-show-recorder defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#start daemon
print "* Waiting for show-recorder processes to start..."
p = Popen("/etc/init.d/airtime-show-recorder stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-show-recorder start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
if os.environ["disable_auto_start_services"] == "f":
#register init.d script
p = Popen("update-rc.d airtime-show-recorder defaults >/dev/null 2>&1", shell=True)
sts = os.waitpid(p.pid, 0)[1]
#start daemon
print "* Waiting for show-recorder processes to start..."
p = Popen("/etc/init.d/airtime-show-recorder stop", shell=True)
sts = os.waitpid(p.pid, 0)[1]
p = Popen("/etc/init.d/airtime-show-recorder start-no-monit", shell=True)
sts = os.waitpid(p.pid, 0)[1]
except Exception, e:
print e

View File

@ -79,7 +79,7 @@ if(Application_Model_Preference::GetSupportFeedback() == '1'){
// Get latest version from stat server and store to db
if(Application_Model_Preference::GetPlanLevel() == 'disabled'){
$url = 'http://stat.sourcefabric.org/airtime_latest_version';
$url = 'http://stat.sourcefabric.org/airtime-stats/airtime_latest_version';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);