From 0d45d7b8cd8995050110a265400ab8786906d145 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 7 Apr 2013 20:19:51 -0400 Subject: [PATCH 1/4] CC-5042: Do process matching by process name instead of PID file -fixed --- python_apps/pypo/airtime-liquidsoap-init-d | 11 ++++++++--- python_apps/pypo/monit-airtime-liquidsoap.cfg | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/python_apps/pypo/airtime-liquidsoap-init-d b/python_apps/pypo/airtime-liquidsoap-init-d index 26d8e3d2b..be9761f17 100755 --- a/python_apps/pypo/airtime-liquidsoap-init-d +++ b/python_apps/pypo/airtime-liquidsoap-init-d @@ -15,6 +15,7 @@ NAME="Liquidsoap Playout Engine" DAEMON=/usr/lib/airtime/pypo/bin/airtime-liquidsoap PIDFILE=/var/run/airtime-liquidsoap.pid +EXEC='/usr/bin/airtime-liquidsoap' start () { chown pypo:pypo /var/log/airtime/pypo @@ -24,8 +25,10 @@ start () { touch $PIDFILE chown pypo:pypo $PIDFILE + #start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \ + #--pidfile $PIDFILE --nicelevel -15 --startas $DAEMON start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \ - --pidfile $PIDFILE --nicelevel -15 --startas $DAEMON + --nicelevel -15 --startas $DAEMON --exec $EXEC } stop () { @@ -33,9 +36,11 @@ stop () { timeout -s9 10s /usr/lib/airtime/airtime_virtualenv/bin/python \ /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_prepare_terminate.py # Send TERM after 5 seconds, wait at most 30 seconds. - start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE + #start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --pidfile $PIDFILE + start-stop-daemon --stop --oknodo --retry=TERM/10/KILL/5 --quiet --exec $EXEC + rm -f $PIDFILE - sleep 3 + sleep 2 } start_with_monit () { diff --git a/python_apps/pypo/monit-airtime-liquidsoap.cfg b/python_apps/pypo/monit-airtime-liquidsoap.cfg index 388f6c72b..8688251ea 100644 --- a/python_apps/pypo/monit-airtime-liquidsoap.cfg +++ b/python_apps/pypo/monit-airtime-liquidsoap.cfg @@ -3,8 +3,7 @@ set httpd port 2812 - check process airtime-liquidsoap - with pidfile "/var/run/airtime-liquidsoap.pid" + check process airtime-liquidsoap matching "airtime-liquidsoap.*airtime.*ls_script" start program = "/etc/init.d/airtime-liquidsoap start" with timeout 30 seconds stop program = "/etc/init.d/airtime-liquidsoap stop" From 67cdfd4b091fd981110a69f7b473047ea5f64321 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 7 Apr 2013 20:20:14 -0400 Subject: [PATCH 2/4] when doing reinstall, make sure monit isn't restarting services --- install_minimal/airtime-install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 68005f54b..647db6c8b 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -143,6 +143,11 @@ fi #We don't want any of our python services running if we are doing an upgrade/reinstall. #They will be automatically restarted later on. echo "* Temporarily stopping any previous running services" +set +e +monit unmonitor airtime-media-monitor >/dev/null 2>&1 +monit unmonitor airtime-liquidsoap >/dev/null 2>&1 +monit unmonitor airtime-playout >/dev/null 2>&1 +set -e if [ -e /etc/init.d/airtime-media-monitor ]; then invoke-rc.d airtime-media-monitor stop > /dev/null 2>&1 fi From 670566954905cc663c48f87130b2418557b3ee79 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 7 Apr 2013 20:20:21 -0400 Subject: [PATCH 3/4] code cleanup --- install_minimal/include/airtime-uninitialize.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/install_minimal/include/airtime-uninitialize.sh b/install_minimal/include/airtime-uninitialize.sh index c76bcdfd6..50a4ccf70 100755 --- a/install_minimal/include/airtime-uninitialize.sh +++ b/install_minimal/include/airtime-uninitialize.sh @@ -21,13 +21,9 @@ monit unmonitor airtime-liquidsoap >/dev/null 2>&1 monit unmonitor airtime-playout >/dev/null 2>&1 set -e -#virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" -#. ${virtualenv_bin}activate - #uninitialize Airtime services python $AIRTIMEROOT/python_apps/pypo/install/pypo-uninitialize.py python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-uninitialize.py -#python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-uninitialize.py if [ "$purge" = "t" ]; then #call Airtime uninstall script From aca651a1b43f86039efe73838f647217845093f1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 8 Apr 2013 18:53:35 -0400 Subject: [PATCH 4/4] better logging --- install_minimal/airtime-install | 3 +++ install_minimal/include/airtime-copy-files.sh | 1 - install_minimal/include/airtime-install.php | 2 +- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 1 + python_apps/pypo/pypofetch.py | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 68005f54b..8728013e6 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -172,6 +172,8 @@ set -e echo -e "\n******************************** Install Begin *********************************" rm -rf "/usr/lib/airtime" +mkdir -p /usr/lib/airtime + if [ "$python_service" -eq "0" ]; then $AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh @@ -208,6 +210,7 @@ if [ "$mediamonitor" = "t" -o "$pypo" = "t" ]; then fi +#An attempt to force apache to realize that files are updated on upgrade... touch /usr/share/airtime/public/index.php if [ "$python_service" -eq "0" ]; then diff --git a/install_minimal/include/airtime-copy-files.sh b/install_minimal/include/airtime-copy-files.sh index 20b128a68..ced1786de 100755 --- a/install_minimal/include/airtime-copy-files.sh +++ b/install_minimal/include/airtime-copy-files.sh @@ -72,7 +72,6 @@ if [ "$python_service" -eq "0" ]; then fi fi -mkdir -p /usr/lib/airtime cp -R $AIRTIMEROOT/utils /usr/lib/airtime cp -R $AIRTIMEROOT/python_apps/std_err_override /usr/lib/airtime diff --git a/install_minimal/include/airtime-install.php b/install_minimal/include/airtime-install.php index bbd0c157a..ec7829269 100644 --- a/install_minimal/include/airtime-install.php +++ b/install_minimal/include/airtime-install.php @@ -13,7 +13,7 @@ require_once(__DIR__.'/airtime-constants.php'); // ------------------------------------------------------------------------- $iniExists = file_exists("/etc/airtime/airtime.conf"); -if ($iniExists){ +if ($iniExists) { //reinstall, Will ask if we should rewrite config files. require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); $CC_CONFIG = Config::getConfig(); diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 1df261316..b7de38b3d 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -192,6 +192,7 @@ def check_dj_client(user,password) = ret = get_process_lines("python /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap_auth.py --dj #{user} #{password}") #ret has now the value of the live client (dj1,dj2, or djx), or "ERROR"/"unknown" ... hd = list.hd(ret) + log("Live DJ authenticated: #{hd}") hd == "True" end diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 7c50b4e2d..06e5607df 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -142,7 +142,7 @@ class PypoFetch(Thread): tn.write('exit\n') tn.read_all() except Exception, e: - logger.error(str(e)) + logger.error(traceback.format_exc()) finally: lock.release()