From d8ff6ae86714cb2ee6b14f88a7b921f5d9432738 Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 23 Jun 2011 13:41:46 -0400 Subject: [PATCH 1/2] CC-2416: airtime-check-system: add status of "pyinotify" and "mutagen" -done. Also prints out why the check failed (if version number is too old) --- utils/airtime-check-system.php | 53 ++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index e76fb66e1..76d0441d3 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -54,6 +54,11 @@ class AirtimeCheck { const CHECK_OK = "OK"; const CHECK_FAILED = "FAILED"; + const KOMBU_MIN_VERSION = "1.1.2"; + const POSTER_MIN_VERSION = "0.8.1"; + const MUTAGEN_MIN_VERSION = "1.20"; + const PYINOTIFY_MIN_VERSION = "0.9.2"; + public static $check_system_ok = true; private static function CheckAirtimeDaemonRunning($filename, $process_id_str, $process_running_str, $name, $logFile) @@ -231,34 +236,52 @@ class AirtimeCheck { output_status("POSTGRESQL_DATABASE", $status); } - public static function PythonLibrariesInstalled() - { - $command = "pip freeze | grep kombu"; - exec($command, $output, $result); + private static function isMinVersionSatisfied($minVersion, $version){ + $minVersionArr = explode(".", $minVersion); + $versionArr = explode(".", $version); - $status = AirtimeCheck::CHECK_FAILED; - if (count($output[0]) > 0){ - $key_value = explode("==", $output[0]); - $status = trim($key_value[1]); - } else { - self::$check_system_ok = false; + if (count($minVersionArr) != count($versionArr)){ + return false; } - output_status("PYTHON_KOMBU_VERSION", $status); + //when comparing 1.20 and 1.19, first compare "1" and "1" + //and then the "20" to the "19" + for ($i=0, $n = count($minVersionArr); $i<$n; $i++){ + if ($minVersionArr[$i] > $versionArr[$i]){ + return false; + } + } - unset($output); - $command = "pip freeze | grep poster"; + return true; + } + + private static function CheckPythonLibrary($lib, $minVersion){ + $command = "pip freeze | grep $lib"; exec($command, $output, $result); $status = AirtimeCheck::CHECK_FAILED; if (count($output[0]) > 0){ $key_value = explode("==", $output[0]); - $status = trim($key_value[1]); + $version = trim($key_value[1]); + if (self::isMinVersionSatisfied($minVersion, $version)){ + $status = $version; + } else { + output_msg("Minimum require version for \"$lib\" is $minVersion. Your version: $version"); + self::$check_system_ok = false; + } } else { self::$check_system_ok = false; } - output_status("PYTHON_POSTER_VERSION", $status); + return $status; + } + + public static function PythonLibrariesInstalled() + { + output_status("PYTHON_KOMBU_VERSION", self::CheckPythonLibrary("kombu", self::KOMBU_MIN_VERSION)); + output_status("PYTHON_POSTER_VERSION", self::CheckPythonLibrary("poster", self::POSTER_MIN_VERSION)); + output_status("PYTHON_MUTAGEN_VERSION", self::CheckPythonLibrary("mutagen", self::MUTAGEN_MIN_VERSION)); + output_status("PYTHON_PYINOTIFY_VERSION", self::CheckPythonLibrary("pyinotify", self::PYINOTIFY_MIN_VERSION)); } public static function CheckDbTables() From 95b69b403b24f81d55065d005f5b874181d88a2d Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 23 Jun 2011 14:06:02 -0400 Subject: [PATCH 2/2] CC-2429: Liquidsoap should be run with higher priority -On a range of -20 to 20, where -20 gives the highest priority, set Liquidsoap nice to -15. --- python_apps/pypo/airtime-playout-init-d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python_apps/pypo/airtime-playout-init-d b/python_apps/pypo/airtime-playout-init-d index b07a97d5d..dabc0dac5 100755 --- a/python_apps/pypo/airtime-playout-init-d +++ b/python_apps/pypo/airtime-playout-init-d @@ -24,7 +24,8 @@ start () { start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE0 --startas $DAEMON0 monit monitor airtime-liquidsoap >/dev/null 2>&1 - start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID --make-pidfile --pidfile $PIDFILE1 --startas $DAEMON1 + start-stop-daemon --start --background --quiet --chuid $USERID:$GROUPID \ + --nicelevel -15 --make-pidfile --pidfile $PIDFILE1 --startas $DAEMON1 } stop () {