diff --git a/loction_server/api_get_nearby.php b/loction_server/api_get_nearby.php index 2c82f966..df5b18f8 100755 --- a/loction_server/api_get_nearby.php +++ b/loction_server/api_get_nearby.php @@ -26,13 +26,14 @@ if (!$lat || !$lng) { echo json_encode(['status' => false, 'msg' => 'Invalid Coordinates']); exit; } -try { - $redis = new Client(['scheme'=>'tcp', - 'host'=>'127.0.0.1', - 'password' => $PASS_REDIS, - 'port'=>6379, - 'database' => 0] - ); + $redisHost = getenv('REDIS_HOST') ?: ($_ENV['REDIS_HOST'] ?? (file_exists('/.dockerenv') ? 'redis' : '127.0.0.1')); + $redis = new Client([ + 'scheme' => 'tcp', + 'host' => $redisHost, + 'password' => $PASS_REDIS, + 'port' => 6379, + 'database' => 0 + ]); $redis->connect(); // 🔥 التعديل هنا: إضافة WITHCOORD لجلب الإحداثيات من الريدز مباشرة diff --git a/loction_server/driver_socket.php b/loction_server/driver_socket.php index 443ee71f..359a6143 100755 --- a/loction_server/driver_socket.php +++ b/loction_server/driver_socket.php @@ -101,10 +101,11 @@ function getRedis(): ?RedisClient { } try { + $redisHost = getenv('REDIS_HOST') ?: ($_ENV['REDIS_HOST'] ?? (file_exists('/.dockerenv') ? 'redis' : '127.0.0.1')); $client = new RedisClient([ 'scheme' => 'tcp', - 'host' => '127.0.0.1', - 'port' => 6379, + 'host' => $redisHost, + 'port' => (int)(getenv('REDIS_PORT') ?: 6379), 'password' => $redisPass, 'read_write_timeout' => 0, ]);