Simplify configuration file structure
This removes most of the legacy upstream config madness by not using weird config files spread all over the place. This isn't the solution to other config reading fragility issues, but it does move the whole config back to the central airtime.conf file.
This commit is contained in:
parent
320b128ad8
commit
fa2018a2c5
14 changed files with 46 additions and 106 deletions
|
@ -55,7 +55,7 @@ class CeleryManager {
|
|||
* results asynchronously later
|
||||
*/
|
||||
public static function sendCeleryMessage($task, $exchange, $data) {
|
||||
$config = parse_ini_file(Application_Model_RabbitMq::getRmqConfigPath(), true);
|
||||
$config = Config::getConfig();
|
||||
$queue = $routingKey = $exchange;
|
||||
$c = self::_setupCeleryExchange($config, $exchange, $queue); // Use the exchange name for the queue
|
||||
$result = $c->PostTask($task, $data, true, $routingKey); // and routing key
|
||||
|
@ -75,7 +75,7 @@ class CeleryManager {
|
|||
* $_CELERY_MESSAGE_TIMEOUT milliseconds have passed
|
||||
*/
|
||||
private static function getAsyncResultMessage($task) {
|
||||
$config = parse_ini_file(Application_Model_RabbitMq::getRmqConfigPath(), true);
|
||||
$config = Config::getConfig();
|
||||
$queue = self::$_CELERY_RESULTS_EXCHANGE . "." . $task;
|
||||
$c = self::_setupCeleryExchange($config, self::$_CELERY_RESULTS_EXCHANGE, $queue);
|
||||
$message = $c->getAsyncResultMessage($task->getDbName(), $task->getDbTaskId());
|
||||
|
@ -208,4 +208,4 @@ class CeleryManager {
|
|||
return (empty($dispatchTime) || $dispatchTime->add($timeoutInterval) <= $now);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,20 +49,13 @@ class Config {
|
|||
$CC_CONFIG['staticBaseDir'] = '/';
|
||||
}
|
||||
|
||||
// Parse separate conf file for cloud storage values
|
||||
$cloudStorageConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/cloud_storage.conf";
|
||||
if (!file_exists($cloudStorageConfig)) {
|
||||
// If the dev env specific cloud_storage.conf doesn't exist default
|
||||
// to the production cloud_storage.conf
|
||||
$cloudStorageConfig = LIBRETIME_CONF_DIR . "/production/cloud_storage.conf";
|
||||
}
|
||||
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
|
||||
|
||||
$CC_CONFIG["supportedStorageBackends"] = array('amazon_S3');
|
||||
foreach ($CC_CONFIG["supportedStorageBackends"] as $backend) {
|
||||
$CC_CONFIG[$backend] = $cloudStorageValues[$backend];
|
||||
}
|
||||
|
||||
$CC_CONFIG['amazon_S3'] = array(
|
||||
'provider' => $values['amazon_S3']['provider'],
|
||||
'bucket' => $values['amazon_S3']['bucket'],
|
||||
'api_key' => $values['amazon_S3']['api_key'],
|
||||
'api_key_secret' => $values['amazon_S3']['api_key_secret']
|
||||
);
|
||||
|
||||
// Tells us where file uploads will be uploaded to.
|
||||
// It will either be set to a cloud storage backend or local file storage.
|
||||
$CC_CONFIG["current_backend"] = $cloudStorageValues["current_backend"]["storage_backend"];
|
||||
|
@ -81,20 +74,13 @@ class Config {
|
|||
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
|
||||
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
|
||||
|
||||
$globalAirtimeConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/airtime.conf";
|
||||
if (!file_exists($globalAirtimeConfig)) {
|
||||
// If the dev env specific airtime.conf doesn't exist default
|
||||
// to the production airtime.conf
|
||||
$globalAirtimeConfig = LIBRETIME_CONF_DIR . "/production/airtime.conf";
|
||||
}
|
||||
$globalAirtimeConfigValues = parse_ini_file($globalAirtimeConfig, true);
|
||||
$CC_CONFIG['soundcloud-client-id'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_id'];
|
||||
$CC_CONFIG['soundcloud-client-secret'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_secret'];
|
||||
$CC_CONFIG['soundcloud-redirect-uri'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_redirect_uri'];
|
||||
if (isset($globalAirtimeConfigValues['facebook']['facebook_app_id'])) {
|
||||
$CC_CONFIG['facebook-app-id'] = $globalAirtimeConfigValues['facebook']['facebook_app_id'];
|
||||
$CC_CONFIG['facebook-app-url'] = $globalAirtimeConfigValues['facebook']['facebook_app_url'];
|
||||
$CC_CONFIG['facebook-app-api-key'] = $globalAirtimeConfigValues['facebook']['facebook_app_api_key'];
|
||||
$CC_CONFIG['soundcloud-client-id'] = $values['soundcloud']['soundcloud_client_id'];
|
||||
$CC_CONFIG['soundcloud-client-secret'] = $values['soundcloud']['soundcloud_client_secret'];
|
||||
$CC_CONFIG['soundcloud-redirect-uri'] = $values['soundcloud']['soundcloud_redirect_uri'];
|
||||
if (isset($values['facebook']['facebook_app_id'])) {
|
||||
$CC_CONFIG['facebook-app-id'] = $values['facebook']['facebook_app_id'];
|
||||
$CC_CONFIG['facebook-app-url'] = $values['facebook']['facebook_app_url'];
|
||||
$CC_CONFIG['facebook-app-api-key'] = $values['facebook']['facebook_app_api_key'];
|
||||
}
|
||||
|
||||
// ldap config
|
||||
|
|
|
@ -78,29 +78,11 @@ class Application_Model_RabbitMq
|
|||
self::sendMessage($exchange, 'direct', true, $data);
|
||||
}
|
||||
|
||||
public static function getRmqConfigPath() {
|
||||
//Hack for Airtime Pro. The RabbitMQ settings for communicating with airtime_analyzer are global
|
||||
//and shared between all instances on Airtime Pro.
|
||||
//
|
||||
// todo: rewrite me to only use the config class and not access /etc/airtime directly
|
||||
$CC_CONFIG = Config::getConfig();
|
||||
$devEnv = "production"; //Default
|
||||
if (array_key_exists("dev_env", $CC_CONFIG)) {
|
||||
$devEnv = $CC_CONFIG["dev_env"];
|
||||
}
|
||||
$rmq_config_path = LIBRETIME_CONF_DIR . '/' . $devEnv."/rabbitmq-analyzer.ini";
|
||||
if (!file_exists($rmq_config_path)) {
|
||||
// If the dev env specific rabbitmq-analyzer.ini doesn't exist default
|
||||
// to the production rabbitmq-analyzer.ini
|
||||
$rmq_config_path = LIBRETIME_CONF_PATH . "/production/rabbitmq-analyzer.ini";
|
||||
}
|
||||
return $rmq_config_path;
|
||||
}
|
||||
|
||||
public static function SendMessageToAnalyzer($tmpFilePath, $importedStorageDirectory, $originalFilename,
|
||||
$callbackUrl, $apiKey, $storageBackend, $filePrefix)
|
||||
{
|
||||
$config = parse_ini_file(self::getRmqConfigPath(), true);
|
||||
$config = Config::getConfig();
|
||||
|
||||
$conn = new \PhpAmqpLib\Connection\AMQPConnection($config["rabbitmq"]["host"],
|
||||
$config["rabbitmq"]["port"],
|
||||
$config["rabbitmq"]["user"],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue