Initial work on switching media-monitor to use setuptools

This commit is contained in:
Duncan Sommerville 2014-12-19 12:26:41 -05:00
parent 9c324c1b6f
commit ae6352a057
76 changed files with 98 additions and 35 deletions

View File

@ -19,7 +19,6 @@ patch
php5-curl
mpg123
monit
libcamomile-ocaml-data
libpulse0

View File

@ -19,7 +19,6 @@ patch
php5-curl
mpg123
monit
libcamomile-ocaml-data
libpulse0

View File

@ -348,8 +348,12 @@ cp -R ${AIRTIMEROOT}/python_apps/api_clients /usr/lib/airtime/api_clients
verbose "...Done"
verbose "\n * Copying media-monitor files..."
cp -R ${AIRTIMEROOT}/python_apps/media-monitor /usr/lib/airtime/media-monitor
cp -R ${AIRTIMEROOT}/python_apps/media-monitor2 /usr/lib/airtime/media-monitor/mm2
cp -R ${AIRTIMEROOT}/python_apps/media-monitor/media-monitor /usr/lib/airtime/media-monitor
cp -R ${AIRTIMEROOT}/python_apps/media-monitor/media-monitor2 /usr/lib/airtime/media-monitor/mm2
verbose "...Done"
verbose "\n * Installing media-monitor..."
python ${AIRTIMEROOT}/python_apps/media-monitor/setup.py install
verbose "...Done"
verbose "\n * Copying pypo files..."

View File

@ -0,0 +1,15 @@
description "Airtime Media Monitor"
author "help@sourcefabric.org"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid www-data
setgid www-data
env LANG='en_US.UTF-8'
env LC_ALL='en_US.UTF-8'
exec airtime-media-monitor

View File

@ -1,31 +0,0 @@
api_client = "airtime"
# where the binary files live
bin_dir = '/usr/lib/airtime/media-monitor'
# where the logging files live
log_dir = '/var/log/airtime/media-monitor'
############################################
# RabbitMQ settings #
############################################
rabbitmq_host = 'localhost'
rabbitmq_user = 'guest'
rabbitmq_password = 'guest'
rabbitmq_vhost = '/'
############################################
# Media-Monitor preferences #
############################################
check_filesystem_events = 5 #how long to queue up events performed on the files themselves.
check_airtime_events = 30 #how long to queue metadata input from airtime.
# MM2 only:
touch_interval = 5
chunking_number = 450
request_max_wait = 3.0
rmq_event_wait = 0.1
logpath = '/var/log/airtime/media-monitor/media-monitor.log'
index_path = '/var/tmp/airtime/media-monitor/last_index'

View File

@ -0,0 +1,30 @@
#!/bin/bash
# Location of pypo_cli.py Python script
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
media_monitor_path="/usr/lib/airtime/media-monitor/"
media_monitor_script="media_monitor.py"
api_client_path="/usr/lib/airtime/:/usr/lib/airtime/media-monitor/mm2/"
cd ${media_monitor_path}
exec 2>&1
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/media-monitor/error.log
exit 1
fi
export PYTHONPATH=${api_client_path}
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
exec python ${media_monitor_path}${media_monitor_script} > /var/log/airtime/media-monitor/py-interpreter.log 2>&1
# EOF

View File

@ -0,0 +1,47 @@
from setuptools import setup
from subprocess import call
import sys
import os
script_path = os.path.dirname(os.path.realpath(__file__))
print script_path
os.chdir(script_path)
# Allows us to avoid installing the upstart init script when deploying on Airtime Pro:
if '--no-init-script' in sys.argv:
data_files = []
sys.argv.remove('--no-init-script') # super hax
else:
data_files = [('/etc/init', ['install/airtime-media.conf'])]
print data_files
setup(name='airtime-media-monitor',
version='1.0',
description='Airtime Media Monitor',
url='http://github.com/sourcefabric/Airtime',
author='sourcefabric',
license='AGPLv3',
packages=['media-monitor', 'media-monitor2'],
scripts=['bin/airtime-media-monitor'],
install_requires=[
'amqplib',
'anyjson',
'argparse',
'configobj',
'docopt',
'kombu',
'mutagen',
'poster',
'PyDispatcher',
'pyinotify',
'pytz',
'wsgiref'
],
zip_safe=False,
data_files=data_files)
# Reload the initctl config so that playout services works
if data_files:
print "Reloading initctl configuration"
call(['initctl', 'reload-configuration'])
print "Run \"sudo service airtime-media-monitor start\""