Add database and Redis port configuration support, connection health checks, and refactor worker status endpoint.

This commit is contained in:
Jeppe Bundgaard
2026-03-20 13:01:21 +01:00
parent 219f739b54
commit de89c4d635
7 changed files with 138 additions and 21 deletions
+27 -6
View File
@@ -10,6 +10,7 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
'CONFIG_DB_USER' => 'user',
'CONFIG_DB_PASSWORD' => 'password',
'CONFIG_DB_DATABASE' => 'database',
'CONFIG_DB_PORT' => 'port',
'DEBUG' => 'DEBUG',
'ENCRYPTION_KEY' => 'ENCRYPTION_KEY',
'CORS' => 'CORS',
@@ -25,7 +26,9 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
'SLACK_DEFAULT_WEBHOOK' => 'SLACK_DEFAULT_WEBHOOK',
'REDIS_CONFIG_HOST' => 'host',
'REDIS_CONFIG_DATABASE' => 'database',
'REDIS_CONFIG_PASSWORD' => 'password'
'REDIS_CONFIG_PASSWORD' => 'password',
'REDIS_CONFIG_PORT' => 'port',
'REDIS_CONFIG_USER' => 'user'
];
$dbTarget = strtolower(trim((string)($_ENV['CONFIG_DB_TARGET'] ?? 'live')));
if ($dbTarget !== 'live' && $dbTarget !== 'debug') {
@@ -52,7 +55,9 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
'host' => $resolveDbValue('HOST'),
'user' => $resolveDbValue('USER'),
'password' => $resolveDbValue('PASSWORD'),
'database' => $resolveDbValue('DATABASE')
'database' => $resolveDbValue('DATABASE'),
'port' => (int)($resolveDbValue('PORT') ?: 3306),
'ssl_mode' => $resolveDbValue('SSL_MODE') ?: 'DISABLED'
];
/**
* Set the debug configuration
@@ -98,17 +103,33 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
* Set the Slack default webhook
*/
$SLACK_DEFAULT_WEBHOOK = $_ENV['SLACK_DEFAULT_WEBHOOK'];
$resolveRedisValue = function (string $key) use ($dbTarget): string {
$liveKey = 'REDIS_CONFIG_' . $key;
$debugKey = 'REDIS_CONFIG_DEBUG_' . $key;
$liveValue = (string)($_ENV[$liveKey] ?? '');
$debugValue = (string)($_ENV[$debugKey] ?? '');
if ($dbTarget === 'debug' && $debugValue !== '') {
return $debugValue;
}
return $liveValue;
};
/**
* Set the Redis configuration
*/
$REDIS_CONFIG = [
'host' => $_ENV['REDIS_CONFIG_HOST'],
'database' => $_ENV['REDIS_CONFIG_DATABASE'],
'password' => $_ENV['REDIS_CONFIG_PASSWORD']
'host' => $resolveRedisValue('HOST'),
'user' => $resolveRedisValue('USER'),
'database' => $resolveRedisValue('DATABASE'),
'password' => $resolveRedisValue('PASSWORD'),
'port' => (int)($resolveRedisValue('PORT') ?: 6379)
];
// Set the timezone
date_default_timezone_set($_ENV['CONFIG_TIMEZONE']) ?? 'Europe/Copenhagen';
$timezone = $_ENV['CONFIG_TIMEZONE'] ?? 'Europe/Copenhagen';
date_default_timezone_set($timezone);
// Set the all config
$ALL_CONFIG = $_ENV; // This is used by the backup job.