Skip to content

Commit

Permalink
UHF-9099: Set unique artemis destination per instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tuutti committed Oct 6, 2023
1 parent 686c151 commit e6f7224
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OC_PROJECT_NAME=
# Leave empty if the project is not a part of the Hel.fi ecosystem.
PROJECT_NAME=

# Default Docker compose profiles. See https://docs.docker.com/compose/profiles/
# Default Docker compose profiles. See https://docs.docker.com/compose/profiles/.
COMPOSE_PROFILES=

# Stage file proxy origin url and folder
Expand Down
27 changes: 26 additions & 1 deletion public/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,28 @@
ini_set('zend.enable_gc', 'Off');
}

/**
* Gets the value of given environment variable.
*
* @param string|array $variables
* The variables to scan.
*
* @return mixed
* The value.
*/
function drupal_get_env(string|array $variables) : mixed {
if (!is_array($variables)) {
$variables = [$variables];
}

foreach ($variables as $var) {
if ($value = getenv($var)) {
return $value;
}
}
return NULL;
}

if ($simpletest_db = getenv('SIMPLETEST_DB')) {
$parts = parse_url($simpletest_db);
putenv(sprintf('DRUPAL_DB_NAME=%s', substr($parts['path'], 1)));
Expand Down Expand Up @@ -205,11 +227,14 @@
$config['helfi_proxy.settings']['robots_header_enabled'] = (bool) $robots_header_enabled;
}

if ($artemis_brokers = getenv('ARTEMIS_BROKERS')) {
$artemis_destination = drupal_get_env(['ARTEMIS_DESTINATION', 'PROJECT_NAME']);

if ($artemis_brokers = getenv('ARTEMIS_BROKERS') && $artemis_destination) {
$settings['stomp']['default'] = [
'clientId' => getenv('ARTEMIS_CLIENT_ID') ?: 'artemis',
'login' => getenv('ARTEMIS_LOGIN'),
'passcode' => getenv('ARTEMIS_PASSCODE'),
'destination' => sprintf('/queue/%s', $artemis_destination),
'brokers' => $artemis_brokers,
'timeout' => ['read' => 15000],
'heartbeat' => [
Expand Down

0 comments on commit e6f7224

Please sign in to comment.