Merge branch 'saas' into cc-5709-airtime-analyzer-cloud-storage-saas

Conflicts:
	.gitignore
	airtime_mvc/application/configs/airtime-conf.php
	airtime_mvc/application/configs/classmap-airtime-conf.php
	airtime_mvc/application/models/RabbitMq.php
	airtime_mvc/application/models/Schedule.php
	airtime_mvc/application/models/StoredFile.php
	airtime_mvc/application/models/airtime/map/CcShowInstancesTableMap.php
	airtime_mvc/application/models/airtime/map/CcShowTableMap.php
	airtime_mvc/application/models/airtime/om/BaseCcShow.php
	airtime_mvc/application/models/airtime/om/BaseCcShowInstances.php
	airtime_mvc/application/models/airtime/om/BaseCcShowInstancesPeer.php
	airtime_mvc/application/models/airtime/om/BaseCcShowInstancesQuery.php
	airtime_mvc/application/models/airtime/om/BaseCcShowPeer.php
	airtime_mvc/application/models/airtime/om/BaseCcShowQuery.php
	airtime_mvc/application/modules/rest/Bootstrap.php
	airtime_mvc/application/modules/rest/controllers/MediaController.php
	airtime_mvc/build/sql/schema.sql
	airtime_mvc/public/index.php
This commit is contained in:
drigato 2014-11-03 12:29:58 -05:00
commit 0a45de7fba
163 changed files with 67857 additions and 56085 deletions

View file

@ -1,11 +1,16 @@
#! /bin/bash
#!/bin/bash -xv
post_file() {
#kill process after 30 minutes (360*5=30 minutes)
max_retry=360
retry_count=0
file_path=${1}
file_path="${1}"
#We must remove commas because CURL can't upload files with commas in the name
# http://curl.haxx.se/mail/archive-2009-07/0029.html
stripped_file_path=${file_path//','/''}
mv "${file_path}" "${stripped_file_path}"
file_path="${stripped_file_path}"
filename="${file_path##*/}"
#base_instance_path and airtime_conf_path are common to all saas instances
@ -28,7 +33,9 @@ post_file() {
api_key=$(awk -F "= " '/api_key/ {print $2}' $instance_conf_path)
until curl --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "full_path=${file_path}"
# -f is needed to make curl fail if there's an HTTP error code
# -L is needed to follow redirects! (just in case)
until curl -fL --max-time 30 $url -u $api_key":" -X POST -F "file=@${file_path}" -F "full_path=${file_path}"
do
retry_count=$[$retry_count+1]
if [ $retry_count -ge $max_retry ]; then

View file

@ -44,10 +44,6 @@ try:
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
config['rabbitmq_user'] = os.environ['RABBITMQ_USER']
config['rabbitmq_password'] = os.environ['RABBITMQ_PASSWORD']
config['rabbitmq_vhost'] = os.environ['RABBITMQ_VHOST']
config.write()
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)

View file

@ -1,6 +1,18 @@
set daemon 10 # Poll at 10 second intervals
set logfile /var/log/monit.log
# set mailserver %%mail_server%% port 25
# set alert support@airtime.pro
# set mail-format {
# from: lxc%%instance_id%%@airtime.pro
# subject: $ACTION $SERVICE (%%mail_server%%)
# message:
# Monit: $ACTION $SERVICE
# Date: $DATE
# Description: $DESCRIPTION.
# }
set httpd port 2812
allow admin:$admin_pass
allow guest:airtime read-only

View file

@ -26,6 +26,10 @@ export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\
export TERM=xterm
#Nothing to do with Pypo, but for container maintenance. Let's parse the IP address
#so we may more easily manage our instance containers
ifconfig eth0 | egrep -o 'inet addr:([0-9]{1,3}\.){3}[0-9]{1,3}' | cut -d':' -f2 > /etc/airtime_ip_addr
exec python ${pypo_path}/${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
# EOF

View file

@ -81,10 +81,6 @@ try:
# load config file
try:
config = ConfigObj(PATH_INI_FILE)
config['rabbitmq_user'] = os.environ['RABBITMQ_USER']
config['rabbitmq_password'] = os.environ['RABBITMQ_PASSWORD']
config['rabbitmq_vhost'] = os.environ['RABBITMQ_VHOST']
config.write()
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)

View file

@ -50,6 +50,7 @@ def create_source()
l = crossfade_airtime(l)
l = on_metadata(notify_queue, l)
sources := list.append([l], !sources)
server.register(namespace="queues",
"s#{!source_id}_skip",
@ -71,7 +72,6 @@ create_source()
create_source()
queue = add(!sources, normalize=false)
pair = insert_metadata(queue)
dynamic_metadata_callback := fst(pair)
queue = snd(pair)

View file

@ -10,10 +10,12 @@ import time
from api_clients import api_client
class ListenerStat(Thread):
HTTP_REQUEST_TIMEOUT = 30 # 30 second HTTP request timeout
def __init__(self, logger=None):
def __init__(self, config, logger=None):
Thread.__init__(self)
self.config = config
self.api_client = api_client.AirtimeApiClient()
if logger is None:
self.logger = logging.getLogger()
@ -50,12 +52,18 @@ class ListenerStat(Thread):
f = urllib2.urlopen(req, timeout=ListenerStat.HTTP_REQUEST_TIMEOUT)
document = f.read()
return document
def get_icecast_stats(self, ip):
url = 'http://%(host)s:%(port)s/admin/stats.xml' % ip
document = self.get_stream_server_xml(ip, url)
document = None
if "airtime.pro" in ip["host"].lower():
url = 'http://%(host)s:%(port)s/stats.xsl' % ip
document = self.get_stream_server_xml(ip, url)
else:
url = 'http://%(host)s:%(port)s/admin/stats.xml' % ip
document = self.get_stream_server_xml(ip, url)
dom = xml.dom.minidom.parseString(document)
sources = dom.getElementsByTagName("source")
@ -158,5 +166,5 @@ if __name__ == "__main__":
# add ch to logger
#logger.addHandler(ch)
ls = ListenerStat(logger)
ls.run()
#ls = ListenerStat(logger=logger)
#ls.run()

View file

@ -289,7 +289,7 @@ if __name__ == '__main__':
recorder.daemon = True
recorder.start()
stat = ListenerStat()
stat = ListenerStat(config)
stat.daemon = True
stat.start()