libretime/legacy/application/check.php

197 lines
4.3 KiB
PHP
Raw Normal View History

2014-11-28 00:48:03 +01:00
<?php
fix(deps): update dependency friendsofphp/php-cs-fixer to <3.46.1 (main) (#2868) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.45.1` -> `<3.46.1` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.46.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3460) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.45.0...v3.46.0) - chore: fix internal typehints in Tokens ([#&#8203;7656](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7656)) - chore: reduce PHPStan baseline ([#&#8203;7643](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7643)) - docs: Show class with unit tests and BC promise info ([#&#8203;7667](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7667)) - feat: change default ruleset to `@PER-CS` (only behind PHP_CS_FIXER_FUTURE_MODE=1) ([#&#8203;7650](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7650)) - feat: Support new/instanceof/use trait in `fully_qualified_strict_types` ([#&#8203;7653](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7653)) - fix: FQCN parse phpdoc using full grammar regex ([#&#8203;7649](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7649)) - fix: Handle FQCN properly with `leading_backslash_in_global_namespace` option enabled ([#&#8203;7654](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7654)) - fix: PhpdocToParamTypeFixerTest - support for arrow functions ([#&#8203;7647](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7647)) - fix: PHP_CS_FIXER_FUTURE_MODE - proper boolean validation ([#&#8203;7651](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7651)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
2024-01-07 13:59:02 +01:00
use PhpAmqpLib\Connection\AMQPStreamConnection;
fix(deps): update dependency friendsofphp/php-cs-fixer to <3.45.1 (main) (#2855) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.43.2` -> `<3.45.1` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/friendsofphp%2fphp-cs-fixer/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/friendsofphp%2fphp-cs-fixer/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/friendsofphp%2fphp-cs-fixer/3.43.1/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/friendsofphp%2fphp-cs-fixer/3.43.1/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.45.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3450) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.44.0...v3.45.0) - feat: Enable symbol importing in `@PhpCsFixer` ruleset ([#&#8203;7629](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7629)) - fix: NoUnneededBracesFixer - improve handling of global namespace ([#&#8203;7639](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7639)) - test: run tests with "short_open_tag" enabled ([#&#8203;7637](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7637)) ### [`v3.44.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3440) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.43.1...v3.44.0) - feat: Introduce percentage bar as new default progress output ([#&#8203;7603](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7603)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
2023-12-30 19:41:50 +01:00
use PhpAmqpLib\Exception\AMQPRuntimeException;
2021-10-11 16:10:47 +02:00
function booleanReduce($a, $b)
{
return $a && $b;
}
2014-11-28 01:10:23 +01:00
/**
* Check to see if Airtime is properly configured.
*
2021-10-11 16:10:47 +02:00
* @return bool true if all Airtime dependencies and services are
* properly configured and running
2014-11-28 01:10:23 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkConfiguration()
{
$r1 = array_reduce(checkPhpDependencies(), 'booleanReduce', true);
$r2 = array_reduce(checkExternalServices(), 'booleanReduce', true);
return $r1 && $r2;
2014-11-28 01:10:23 +01:00
}
2014-11-28 21:30:11 +01:00
/**
* Check for Airtime's PHP dependencies and return an associative
2021-10-11 16:10:47 +02:00
* array with the results.
2014-11-28 21:30:11 +01:00
*
* @return array associative array of dependency check results
*/
2021-10-11 16:10:47 +02:00
function checkPhpDependencies()
{
return [
'postgres' => checkDatabaseDependencies(),
];
2014-11-28 00:48:03 +01:00
}
2014-11-28 21:30:11 +01:00
/**
2021-10-11 16:10:47 +02:00
* Check that the PHP dependencies for the database exist.
2014-11-28 21:30:11 +01:00
*
2021-10-11 16:10:47 +02:00
* @return bool true if the database dependencies exist
2014-11-28 21:30:11 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkDatabaseDependencies()
{
2014-12-01 21:49:53 +01:00
global $extensions;
2014-11-28 21:30:11 +01:00
// Check the PHP extension list for the Postgres db extensions
2021-10-11 16:10:47 +02:00
return in_array('pdo_pgsql', $extensions)
&& in_array('pgsql', $extensions);
2014-11-28 21:30:11 +01:00
}
2014-11-28 00:48:03 +01:00
function with_systemd()
{
return !empty(shell_exec('which systemctl'));
}
/**
* Check that all external services are configured correctly and return an associative
2021-10-11 16:10:47 +02:00
* array with the results.
2020-05-19 16:16:31 +02:00
*
* @return array associative array of external service check results
*/
2021-10-11 16:10:47 +02:00
function checkExternalServices()
{
$result = [
2021-10-11 16:10:47 +02:00
'database' => checkDatabaseConfiguration(),
'rabbitmq' => checkRMQConnection(),
];
if (with_systemd()) {
$result['analyzer'] = checkAnalyzerService();
$result['pypo'] = checkPlayoutService();
$result['liquidsoap'] = checkLiquidsoapService();
$result['celery'] = checkCeleryService();
$result['api'] = checkApiService();
}
return $result;
}
2014-11-28 21:30:11 +01:00
/**
2021-10-11 16:10:47 +02:00
* Check the database configuration by fetching a connection from Propel.
2014-11-28 21:30:11 +01:00
*
2021-10-11 16:10:47 +02:00
* @return bool true if a connection is made to the database
2014-11-28 21:30:11 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkDatabaseConfiguration()
{
configureDatabase();
2014-11-28 00:48:03 +01:00
try {
2014-11-28 21:30:11 +01:00
// Try to establish a database connection. If something goes
// wrong, the database is improperly configured
Propel::getConnection();
Propel::close();
} catch (Exception $exc) {
Logging::error($exc->getMessage());
2014-11-28 00:48:03 +01:00
return false;
}
return true;
}
2014-11-28 21:30:11 +01:00
/**
2021-10-11 16:10:47 +02:00
* Initialize Propel to configure the Airtime database.
2014-11-28 21:30:11 +01:00
*/
2021-10-11 16:10:47 +02:00
function configureDatabase()
{
Propel::init(PROPEL_CONFIG_FILEPATH);
}
2014-12-09 23:48:16 +01:00
/**
2021-10-11 16:10:47 +02:00
* Check that we can connect to RabbitMQ.
2020-05-19 16:16:31 +02:00
*
2014-12-19 17:58:47 +01:00
* @return true if the RabbitMQ connection can be established
2014-12-09 23:48:16 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkRMQConnection()
{
$config = Config::getConfig();
try {
fix(deps): update dependency friendsofphp/php-cs-fixer to <3.46.1 (main) (#2868) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.45.1` -> `<3.46.1` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/friendsofphp%2fphp-cs-fixer/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/friendsofphp%2fphp-cs-fixer/3.45.0/3.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.46.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3460) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.45.0...v3.46.0) - chore: fix internal typehints in Tokens ([#&#8203;7656](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7656)) - chore: reduce PHPStan baseline ([#&#8203;7643](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7643)) - docs: Show class with unit tests and BC promise info ([#&#8203;7667](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7667)) - feat: change default ruleset to `@PER-CS` (only behind PHP_CS_FIXER_FUTURE_MODE=1) ([#&#8203;7650](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7650)) - feat: Support new/instanceof/use trait in `fully_qualified_strict_types` ([#&#8203;7653](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7653)) - fix: FQCN parse phpdoc using full grammar regex ([#&#8203;7649](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7649)) - fix: Handle FQCN properly with `leading_backslash_in_global_namespace` option enabled ([#&#8203;7654](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7654)) - fix: PhpdocToParamTypeFixerTest - support for arrow functions ([#&#8203;7647](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7647)) - fix: PHP_CS_FIXER_FUTURE_MODE - proper boolean validation ([#&#8203;7651](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7651)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
2024-01-07 13:59:02 +01:00
$conn = new AMQPStreamConnection(
$config['rabbitmq']['host'],
$config['rabbitmq']['port'],
$config['rabbitmq']['user'],
$config['rabbitmq']['password'],
$config['rabbitmq']['vhost']
);
return isset($conn);
fix(deps): update dependency friendsofphp/php-cs-fixer to <3.45.1 (main) (#2855) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [friendsofphp/php-cs-fixer](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer) | `<3.43.2` -> `<3.45.1` | [![age](https://developer.mend.io/api/mc/badges/age/packagist/friendsofphp%2fphp-cs-fixer/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/friendsofphp%2fphp-cs-fixer/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/friendsofphp%2fphp-cs-fixer/3.43.1/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/friendsofphp%2fphp-cs-fixer/3.43.1/3.45.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>PHP-CS-Fixer/PHP-CS-Fixer (friendsofphp/php-cs-fixer)</summary> ### [`v3.45.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3450) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.44.0...v3.45.0) - feat: Enable symbol importing in `@PhpCsFixer` ruleset ([#&#8203;7629](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7629)) - fix: NoUnneededBracesFixer - improve handling of global namespace ([#&#8203;7639](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7639)) - test: run tests with "short_open_tag" enabled ([#&#8203;7637](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7637)) ### [`v3.44.0`](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/HEAD/CHANGELOG.md#Changelog-for-v3440) [Compare Source](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.43.1...v3.44.0) - feat: Introduce percentage bar as new default progress output ([#&#8203;7603](https://togithub.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7603)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/libretime/libretime). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMDMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjEwMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: jo <ljonas@riseup.net>
2023-12-30 19:41:50 +01:00
} catch (AMQPRuntimeException $exc) {
Logging::error($exc->getMessage());
2021-10-11 16:10:47 +02:00
return false;
}
}
2014-12-19 17:58:47 +01:00
/**
2021-10-11 16:10:47 +02:00
* Check if airtime-analyzer is currently running.
2020-05-19 16:16:31 +02:00
*
2021-10-11 16:10:47 +02:00
* @return bool true if airtime-analyzer is running
2014-12-19 17:58:47 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkAnalyzerService()
{
exec('systemctl is-active libretime-analyzer --quiet', $out, $status);
2021-10-11 16:10:47 +02:00
return $status == 0;
}
2014-12-19 17:58:47 +01:00
/**
2021-10-12 14:05:55 +02:00
* Check if libretime-playout is currently running.
2020-05-19 16:16:31 +02:00
*
2021-10-12 14:05:55 +02:00
* @return bool true if libretime-playout is running
2014-12-19 17:58:47 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkPlayoutService()
{
exec('systemctl is-active libretime-playout --quiet', $out, $status);
2021-10-11 16:10:47 +02:00
return $status == 0;
}
2014-12-19 17:58:47 +01:00
/**
2021-10-12 14:05:55 +02:00
* Check if libretime-liquidsoap is currently running.
2020-05-19 16:16:31 +02:00
*
2021-10-12 14:05:55 +02:00
* @return bool true if libretime-liquidsoap is running
2014-12-19 17:58:47 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkLiquidsoapService()
{
exec('systemctl is-active libretime-liquidsoap --quiet', $out, $status);
2021-10-11 16:10:47 +02:00
return $status == 0;
}
/**
* Check if libretime-worker is currently running.
2020-05-19 16:16:31 +02:00
*
* @return bool true if libretime-worker is running
*/
2021-10-11 16:10:47 +02:00
function checkCeleryService()
{
exec('systemctl is-active libretime-worker --quiet', $out, $status);
2021-10-11 16:10:47 +02:00
return $status == 0;
}
2020-01-30 14:47:36 +01:00
/**
2021-10-11 16:10:47 +02:00
* Check if libretime-api is currently running.
2020-01-30 14:47:36 +01:00
*
2021-10-11 16:10:47 +02:00
* @return bool true if libretime-api is running
2020-01-30 14:47:36 +01:00
*/
2021-10-11 16:10:47 +02:00
function checkApiService()
{
exec('systemctl status libretime-api --quiet', $out, $status);
2021-10-11 16:10:47 +02:00
2020-01-30 14:47:36 +01:00
return $status == 0;
}