Update: 2026-06-21 02:07:00
This commit is contained in:
@@ -60,14 +60,16 @@ require_once __DIR__ . '/helpers.php';
|
||||
$envFile = getenv('ENV_FILE_PATH') ?: (__DIR__ . '/../.env');
|
||||
loadEnvironment($envFile);
|
||||
|
||||
// 4. Redis Connection (Singleton)
|
||||
// 4. Redis Connections (Dual Architecture)
|
||||
$redis = null;
|
||||
$redisLocation = null;
|
||||
try {
|
||||
if (extension_loaded('redis')) {
|
||||
// --- Main Server Redis ---
|
||||
$redis = new Redis();
|
||||
$redisHost = getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||
$redisPort = (int)(getenv('REDIS_PORT') ?: 6379);
|
||||
$redisPass = getenv('REDIS_PASSWORD');
|
||||
$redisHost = getenv('REDIS_MAIN_HOST') ?: getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||
$redisPort = (int)(getenv('REDIS_MAIN_PORT') ?: getenv('REDIS_PORT') ?: 6379);
|
||||
$redisPass = getenv('REDIS_MAIN_PASSWORD') ?: getenv('REDIS_MAIN_AUTH') ?: getenv('REDIS_PASSWORD') ?: getenv('REDIS_AUTH');
|
||||
|
||||
if ($redis->connect($redisHost, $redisPort, 1.5)) {
|
||||
if ($redisPass) $redis->auth($redisPass);
|
||||
@@ -75,10 +77,24 @@ try {
|
||||
} else {
|
||||
$redis = null;
|
||||
}
|
||||
|
||||
// --- Location Server Redis ---
|
||||
$redisLocation = new Redis();
|
||||
$locHost = getenv('REDIS_LOCATION_HOST') ?: $redisHost;
|
||||
$locPort = (int)(getenv('REDIS_LOCATION_PORT') ?: $redisPort);
|
||||
$locPass = getenv('REDIS_LOCATION_PASSWORD') ?: $redisPass;
|
||||
|
||||
if ($redisLocation->connect($locHost, $locPort, 1.5)) {
|
||||
if ($locPass) $redisLocation->auth($locPass);
|
||||
// No prefix for location server
|
||||
} else {
|
||||
$redisLocation = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log("[REDIS] Connection failed: " . $e->getMessage());
|
||||
$redis = null;
|
||||
$redisLocation = null;
|
||||
}
|
||||
|
||||
// 5. تحميل الـ Services الأساسية
|
||||
|
||||
Reference in New Issue
Block a user