Fixed everything about Airtime on Debian

* Added sysvinit scripts back in and cleaned them up
* service status now works correctly for all services
* Moved logging config files into install/ folders for the python_apps
* Fixed some small setup.py problems in the various python_apps
* Gave each python app a better bin/ script which doesn't fork, which lets
  service status work automagically.
This commit is contained in:
Albert Santoni 2015-02-13 16:06:59 -05:00
parent bbcd4fbe2e
commit a2d8da617d
16 changed files with 168 additions and 16 deletions

View File

@ -39,7 +39,7 @@ function checkPhpDependencies() {
*/
function checkZendDependencies() {
return file_exists('/usr/share/php/libzend-framework-php')
|| file_exists('/usr/share/php/zendframework'); // Debian version
|| file_exists('/usr/share/php/Zend'); // Debian version
}
/**
@ -124,7 +124,7 @@ function checkRMQConnection() {
* @return boolean true if airtime-media-monitor is running
*/
function checkMediaMonitorService() {
exec("pgrep -f -u www-data media_monitor", $out, $status);
exec("pgrep -f -u www-data airtime-media-monitor", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}
@ -137,7 +137,7 @@ function checkMediaMonitorService() {
* @return boolean true if airtime-playout is running
*/
function checkPlayoutService() {
exec("pgrep -f -u www-data pypo", $out, $status);
exec("pgrep -f -u www-data airtime-playout", $out, $status);
if (array_key_exists(0, $out) && $status == 0) {
return posix_kill(rtrim($out[0]), 0);
}

View File

@ -10,7 +10,7 @@ locale.setlocale(locale.LC_ALL, '')
def run():
global_cfg = '/etc/airtime/airtime.conf'
logging_cfg = os.path.join(os.path.dirname(__file__), 'logging.cfg')
logging_cfg = '/etc/airtime/media_monitor_logging.cfg'
mm2.main( global_cfg, logging_cfg )

View File

@ -22,7 +22,9 @@ else:
mm2_files.append(os.path.join(root, filename))
data_files = [
('/etc/init', ['install/airtime-media-monitor.conf.template']),
('/etc/init', ['install/upstart/airtime-media-monitor.conf.template']),
('/etc/init.d', ['install/sysvinit/airtime-media-monitor']),
('/etc/airtime', ['install/media_monitor_logging.cfg']),
('/var/log/airtime/media-monitor', []),
('/var/tmp/airtime/media-monitor', []),
]

View File

@ -1,3 +1,5 @@
#!/bin/bash -e
#!/usr/bin/python
import runpy
exec python -m liquidsoap 2>&1
# Run the liquidsoap python module
runpy.run_module('liquidsoap')

View File

@ -1,3 +1,5 @@
#!/bin/bash
#!/usr/bin/python
import runpy
runpy.run_module("pypo", run_name="__main__")
exec python -m pypo > /var/log/airtime/pypo/py-interpreter.log 2>&1

View File

@ -0,0 +1,71 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: airtime-liquidsoap
# Required-Start: $local_fs $remote_fs $network $syslog $all
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage airtime-liquidsoap daemon
### END INIT INFO
USERID=www-data
GROUPID=www-data
NAME=airtime-liquidsoap
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
start () {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
}
stop () {
# Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}
case "${1:-''}" in
'start')
# start commands here
echo -n "Starting $NAME: "
start
echo "Done."
;;
'stop')
# stop commands here
echo -n "Stopping $NAME: "
stop
echo "Done."
;;
'restart')
# restart commands here
echo -n "Restarting $NAME: "
stop
start
echo "Done."
;;
'status')
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart|status"
exit 1
;;
esac

View File

@ -0,0 +1,71 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: airtime-playout
# Required-Start: $local_fs $remote_fs $network $syslog $all
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage airtime-playout daemon
### END INIT INFO
USERID=www-data
GROUPID=www-data
NAME=airtime-playout
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions
start () {
start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \
--make-pidfile --pidfile $PIDFILE --startas $DAEMON
}
stop () {
# Send TERM after 5 seconds, wait at most 30 seconds.
start-stop-daemon --stop --oknodo --retry TERM/5/0/30 --quiet --pidfile $PIDFILE
rm -f $PIDFILE
}
case "${1:-''}" in
'start')
# start commands here
echo -n "Starting $NAME: "
start
echo "Done."
;;
'stop')
# stop commands here
echo -n "Stopping $NAME: "
stop
echo "Done."
;;
'restart')
# restart commands here
echo -n "Restarting $NAME: "
stop
start
echo "Done."
;;
'status')
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*) # no parameter specified
echo "Usage: $SELF start|stop|restart|status"
exit 1
;;
esac

View File

@ -39,10 +39,11 @@ def run():
generate_liquidsoap_config(ss)
successful = True
except Exception, e:
print "Unable to connect to the Airtime server."
logging.error(str(e))
logging.error("traceback: %s", traceback.format_exc())
if attempts == max_attempts:
print "Unable to connect to the Airtime server."
logging.error(str(e))
logging.error("traceback: %s", traceback.format_exc())
logging.error("giving up and exiting...")
sys.exit(1)
else:
time.sleep(3)

View File

@ -18,9 +18,12 @@ else:
pypo_files.append(os.path.join(root, filename))
data_files = [
('/etc/init', ['install/airtime-playout.conf.template']),
('/etc/init', ['install/airtime-liquidsoap.conf.template']),
('/etc/airtime', ['pypo/notify_logging.cfg']),
('/etc/init', ['install/upstart/airtime-playout.conf.template']),
('/etc/init', ['install/upstart/airtime-liquidsoap.conf.template']),
('/etc/init.d', ['install/sysvinit/airtime-playout']),
('/etc/init.d', ['install/sysvinit/airtime-liquidsoap']),
('/etc/airtime', ['install/notify_logging.cfg']),
('/etc/airtime', ['install/pypo_logging.cfg']),
('/var/log/airtime/pypo', []),
('/var/log/airtime/pypo-liquidsoap', []),
('/var/tmp/airtime/pypo', []),
@ -36,7 +39,7 @@ setup(name='airtime-playout',
url='http://github.com/sourcefabric/Airtime',
author='sourcefabric',
license='AGPLv3',
packages=['pypo', 'pypo.media.update',
packages=['pypo', 'pypo.media', 'pypo.media.update',
'liquidsoap', 'liquidsoap.library'],
package_data={'': ['*.liq', '*.cfg']},
scripts=[