From c0df1a1aed09cf3e35f278c1a8f6b9275c1b98b4 Mon Sep 17 00:00:00 2001 From: Gerrit Linnemann Date: Sun, 15 Nov 2015 23:18:09 +0100 Subject: [PATCH] kill in stop script --- kitchenradio/app/radio.js | 15 +-------------- kitchenradio/bin/action.sh | 3 ++- kitchenradio/bin/stop_radio.sh | 2 ++ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/kitchenradio/app/radio.js b/kitchenradio/app/radio.js index 23d6689..647cb93 100644 --- a/kitchenradio/app/radio.js +++ b/kitchenradio/app/radio.js @@ -20,8 +20,6 @@ var Log = null var Helper = null; var Conf = null; -var Child = null; - exports.init = function(Express, Configuration) { App = Express; @@ -69,19 +67,8 @@ exports.play = function(idx) { var download = wget.download(channel.stream, m3u); download.on('end', function(output) { Log.inspect('Radio: Download completed', output); - - if(Helper.isDefinedAndNotNull(Child)) { - // kill active instances - try { - Child.kill(); - } catch(err) { - Log.error('Radio: Error killing process'); - } - } - - Child.stdin.pause(); - Child.kill(); + Helper.shspawn(App.get('tools_root')+'action.sh stop'); Helper.shspawn(App.get('tools_root')+'action.sh play'); }); diff --git a/kitchenradio/bin/action.sh b/kitchenradio/bin/action.sh index 364d5e0..48ecc04 100755 --- a/kitchenradio/bin/action.sh +++ b/kitchenradio/bin/action.sh @@ -10,9 +10,10 @@ MY_PATH="$(pwd)" ### PRORGAM -echo "Action: $1" +#echo "Action: $1" case $1 in "play") sh $MY_PATH/bin/start_radio.sh ;; + "stop") sh $MY_PATH/bin/stop_radio.sh ;; *) echo "INVALID ACTION!" ;; esac \ No newline at end of file diff --git a/kitchenradio/bin/stop_radio.sh b/kitchenradio/bin/stop_radio.sh index 1ecf18e..df26190 100755 --- a/kitchenradio/bin/stop_radio.sh +++ b/kitchenradio/bin/stop_radio.sh @@ -13,3 +13,5 @@ MY_PATH="$(pwd)" echo echo "${BGre}Stop playing ...${RCol}" echo + +pkill -f mplayer \ No newline at end of file