From 1edcbc0657eef15122abab3b32c656d6a0886c5d Mon Sep 17 00:00:00 2001 From: Jonas L Date: Mon, 19 Sep 2022 11:56:56 +0200 Subject: [PATCH] feat(legacy): disable services check when missing systemctl (#2160) --- legacy/application/check.php | 22 +- legacy/application/configs/config-check.php | 191 ++++++++-------- .../views/scripts/systemstatus/index.phtml | 215 +++++++++--------- 3 files changed, 224 insertions(+), 204 deletions(-) diff --git a/legacy/application/check.php b/legacy/application/check.php index 896171a03..1e39b3ae6 100644 --- a/legacy/application/check.php +++ b/legacy/application/check.php @@ -45,6 +45,11 @@ function checkDatabaseDependencies() && in_array('pgsql', $extensions); } +function with_systemd() +{ + return !empty(shell_exec('which systemctl')); +} + /** * Check that all external services are configured correctly and return an associative * array with the results. @@ -53,15 +58,20 @@ function checkDatabaseDependencies() */ function checkExternalServices() { - return [ + $result = [ 'database' => checkDatabaseConfiguration(), - 'analyzer' => checkAnalyzerService(), - 'pypo' => checkPlayoutService(), - 'liquidsoap' => checkLiquidsoapService(), 'rabbitmq' => checkRMQConnection(), - 'celery' => checkCeleryService(), - 'api' => checkApiService(), ]; + + if (with_systemd()) { + $result['analyzer'] = checkAnalyzerService(); + $result['pypo'] = checkPlayoutService(); + $result['liquidsoap'] = checkLiquidsoapService(); + $result['celery'] = checkCeleryService(); + $result['api'] = checkApiService(); + } + + return $result; } /** diff --git a/legacy/application/configs/config-check.php b/legacy/application/configs/config-check.php index 85e30e191..d0cbaa253 100644 --- a/legacy/application/configs/config-check.php +++ b/legacy/application/configs/config-check.php @@ -15,12 +15,15 @@ $postgres = $phpDependencies['postgres']; $database = $externalServices['database']; $rabbitmq = $externalServices['rabbitmq']; +$systemd = with_systemd(); -$pypo = $externalServices['pypo']; -$liquidsoap = $externalServices['liquidsoap']; -$analyzer = $externalServices['analyzer']; -$celery = $externalServices['celery']; -$api = $externalServices['api']; +if ($systemd) { + $pypo = $externalServices['pypo']; + $liquidsoap = $externalServices['liquidsoap']; + $analyzer = $externalServices['analyzer']; + $celery = $externalServices['celery']; + $api = $externalServices['api']; +} $r1 = array_reduce($phpDependencies, 'booleanReduce', true); $r2 = array_reduce($externalServices, 'booleanReduce', true); @@ -155,101 +158,103 @@ $result = $r1 && $r2; - - - Media Analyzer - - - - - - - - - - /etc/systemd/system/, - -
systemctl status libretime-analyzer
-
sudo systemctl restart libretime-analyzer + + + + Media Analyzer - - - - - - Pypo - - - - - - - - - /etc/systemd/system/, - -
systemctl status libretime-playout
-
sudo systemctl restart libretime-playout + + - - - - - Liquidsoap - - - - - - - - - /etc/systemd/system/, - -
systemctl status libretime-liquidsoap
-
sudo systemctl restart libretime-liquidsoap - - - - - - Celery - - - - + + + + + /etc/systemd/system/, + +
systemctl status libretime-analyzer
+
sudo systemctl restart libretime-analyzer + + + - - - - - /etc/systemd/system/, - -
systemctl status libretime-worker
-
sudo systemctl restart libretime-worker + + + Pypo + + + + + + + + + /etc/systemd/system/, + +
systemctl status libretime-playout
+
sudo systemctl restart libretime-playout + + + + + + Liquidsoap + + + - - - - - API - - - - - - - - - /etc/init.d/, - -
systemctl status libretime-api
-
sudo systemctl restart libretime-api + + + + + /etc/systemd/system/, + +
systemctl status libretime-liquidsoap
+
sudo systemctl restart libretime-liquidsoap + + + + + + Celery - - + + + + + + + + + /etc/systemd/system/, + +
systemctl status libretime-worker
+
sudo systemctl restart libretime-worker + + + + + + API + + + + + + + + + + /etc/init.d/, + +
systemctl status libretime-api
+
sudo systemctl restart libretime-api + + + + diff --git a/legacy/application/views/scripts/systemstatus/index.phtml b/legacy/application/views/scripts/systemstatus/index.phtml index e5ed76c09..148debb49 100644 --- a/legacy/application/views/scripts/systemstatus/index.phtml +++ b/legacy/application/views/scripts/systemstatus/index.phtml @@ -10,11 +10,14 @@ $postgres = $phpDependencies["postgres"]; $database = $externalServices["database"]; $rabbitmq = $externalServices["rabbitmq"]; -$pypo = $externalServices["pypo"]; -$liquidsoap = $externalServices["liquidsoap"]; -$analyzer = $externalServices["analyzer"]; -$celery = $externalServices['celery']; -$api = $externalServices['api']; +$systemd = with_systemd(); +if ($systemd) { + $pypo = $externalServices['pypo']; + $liquidsoap = $externalServices['liquidsoap']; + $analyzer = $externalServices['analyzer']; + $celery = $externalServices['celery']; + $api = $externalServices['api']; +} $r1 = array_reduce($phpDependencies, "booleanReduce", true); $r2 = array_reduce($externalServices, "booleanReduce", true); @@ -94,111 +97,113 @@ $result = $r1 && $r2; ?> - - - Media Analyzer - - - - - + + + + Media Analyzer + + + + + + "> + /etc/systemd/system/, + +
systemctl status libretime-analyzer
+
sudo systemctl restart libretime-analyzer "> - /etc/systemd/system/, - -
systemctl status libretime-analyzer
-
sudo systemctl restart libretime-analyzer - - - - - - Pypo - - - - - + } + ?> + + + + + Pypo + + + + + + "> + /etc/systemd/system/, + +
systemctl status libretime-playout
+
sudo systemctl restart libretime-playout "> - /etc/systemd/system/, - -
systemctl status libretime-playout
-
sudo systemctl restart libretime-playout - - - - - - Liquidsoap - - - - - + } + ?> + + + + + Liquidsoap + + + + + + "> + /etc/systemd/system/, + +
systemctl status libretime-liquidsoap
+
sudo systemctl restart libretime-liquidsoap "> - /etc/systemd/system/, - -
systemctl status libretime-liquidsoap
-
sudo systemctl restart libretime-liquidsoap - - - - - - Celery - - - - - + } + ?> + + + + + Celery + + + + + + "> + /etc/systemd/system/, + +
systemctl status libretime-worker
+
sudo systemctl restart libretime-worker "> - /etc/systemd/system/, - -
systemctl status libretime-worker
-
sudo systemctl restart libretime-worker - - - - - - API - - - - - + } + ?> + + + + + API + + + + + + "> + /etc/systemd/system/, + +
systemctl status libretime-api
+
sudo systemctl restart libretime-api "> - /etc/systemd/system/, - -
systemctl status libretime-api
-
sudo systemctl restart libretime-api - - - + } + ?> + + +