feat(legacy): improve rabbitmq check (#1839)

This commit is contained in:
Jonas L 2022-05-09 13:21:17 +02:00 committed by GitHub
parent 87ab49c8b9
commit 6a65a7f3f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 13 deletions

View File

@ -1,7 +1,5 @@
<?php <?php
define('RMQ_INI_SECTION', 'rabbitmq');
function booleanReduce($a, $b) function booleanReduce($a, $b)
{ {
return $a && $b; return $a && $b;
@ -102,19 +100,14 @@ function configureDatabase()
*/ */
function checkRMQConnection() function checkRMQConnection()
{ {
// Check for installed config file first, then check in the build directory, $config = Config::getConfig();
if (file_exists(LIBRETIME_CONFIG_FILEPATH)) {
$ini = parse_ini_file(LIBRETIME_CONFIG_FILEPATH, true);
} else {
$ini = parse_ini_file(SAMPLE_CONFIG_FILEPATH, true);
}
$conn = new \PhpAmqpLib\Connection\AMQPStreamConnection( $conn = new \PhpAmqpLib\Connection\AMQPStreamConnection(
$ini[RMQ_INI_SECTION]['host'], $config['rabbitmq']['host'],
$ini[RMQ_INI_SECTION]['port'], $config['rabbitmq']['port'],
$ini[RMQ_INI_SECTION]['user'], $config['rabbitmq']['user'],
$ini[RMQ_INI_SECTION]['password'], $config['rabbitmq']['password'],
$ini[RMQ_INI_SECTION]['vhost'] $config['rabbitmq']['vhost']
); );
return isset($conn); return isset($conn);