CC-4114: separate Liquidsoap into its own init.d script

if liquidsoap restarts, automatically notify pypo
This commit is contained in:
Martin Konecny 2012-08-28 15:00:02 -04:00
parent 8cf048d459
commit 8d81ecf3ad
6 changed files with 59 additions and 2 deletions

View file

@ -55,6 +55,18 @@ case "${1:-''}" in
start
echo "Done."
;;
'status')
if [ -f "/var/run/airtime-liquidsoap.pid" ]; then
pid=`cat /var/run/airtime-liquidsoap.pid`
if [ -d "/proc/$pid" ]; then
echo "Liquidsoap is running"
exit 0
fi
fi
echo "Liquidsoap is not running"
exit 1
;;
'start-no-monit')
# restart commands here
echo -n "Starting $NAME: "

View file

@ -25,6 +25,18 @@ export PYTHONPATH=${api_client_path}:$PYTHONPATH
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
export TERM=xterm
#If Pypo is starting from scratch let's restart Liquidsoap as well. This is so
#that the Liquidsoap queue #is emptied and we can start from a known state.
/etc/init.d/airtime-liquidsoap status
status="$?"
if [ "$status" == "0" ]; then
/etc/init.d/airtime-liquidsoap restart
else
/etc/init.d/airtime-liquidsoap start
fi
exec python ${pypo_path}${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
# EOF

View file

@ -323,4 +323,6 @@ if s3_enable == true then
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, s3_description)
end
#ignore(output.dummy(blank()))
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --liquidsoap-started &"
log(command)
system(command)

View file

@ -42,6 +42,8 @@ parser.add_option("-t", "--time", help="Liquidsoap boot up time", action="store"
parser.add_option("-x", "--source-name", help="source connection name", metavar="source_name")
parser.add_option("-y", "--source-status", help="source connection status", metavar="source_status")
parser.add_option("-w", "--webstream", help="JSON metadata associated with webstream", metavar="json_data")
parser.add_option("-n", "--liquidsoap-started", help="notify liquidsoap started", metavar="json_data", action="store_true", default=True)
# parse options
(options, args) = parser.parse_args()
@ -67,6 +69,11 @@ class Notify:
def __init__(self):
self.api_client = api_client.AirtimeApiClient()
def notify_liquidsoap_started(self):
logger = logging.getLogger("notify")
logger.debug("Notifying server that Liquidsoap has started")
self.api_client.notify_liquidsoap_started()
def notify_media_start_playing(self, data, media_id):
logger = logging.getLogger("notify")
@ -105,7 +112,6 @@ class Notify:
logger.debug('#################################################')
response = self.api_client.notify_webstream_data(data, media_id)
pass
if __name__ == '__main__':
print
@ -140,6 +146,12 @@ if __name__ == '__main__':
n.notify_webstream_data(options.webstream, options.media_id)
except Exception, e:
print e
elif options.liquidsoap_started:
try:
n = Notify()
n.notify_liquidsoap_started()
except Exception, e:
print e
else:
if not options.data:
print "NOTICE: 'data' command-line argument not given."