redis 설정 변경
This commit is contained in:
@@ -28,9 +28,14 @@ class NaverWorker extends BaseCommand
|
||||
|
||||
$redis = new \Redis();
|
||||
try {
|
||||
$redis->connect('redis', 6379);
|
||||
$redis->select(9);
|
||||
CLI::write(CLI::color('🟢 Naver Worker running...', 'green'));
|
||||
// 두 가지 환경 변수 형식 지원 (REDIS_HOST 또는 redis.default.host)
|
||||
$redisHost = getenv('REDIS_HOST') ?: (getenv('redis.default.host') ?: '127.0.0.1');
|
||||
$redisPort = getenv('REDIS_PORT') ?: (getenv('redis.default.port') ?: 6379);
|
||||
$redisDatabase = getenv('REDIS_DATABASE') ?: (getenv('redis.default.database') ?: 9);
|
||||
|
||||
$redis->connect($redisHost, (int)$redisPort);
|
||||
$redis->select((int)$redisDatabase);
|
||||
CLI::write(CLI::color('🟢 Naver Worker running... (Redis: ' . $redisHost . ':' . $redisPort . ' DB:' . $redisDatabase . ')', 'green'));
|
||||
} catch (\Exception $e) {
|
||||
CLI::error("Redis 연결 불가: " . $e->getMessage());
|
||||
return;
|
||||
|
||||
@@ -159,13 +159,13 @@ class Cache extends BaseConfig
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Redis 설정에 .env 값을 할당 (이전 논의된 Docker 호스트 이름 'redis' 사용)
|
||||
// Redis 설정에 환경 변수 값을 할당 (두 가지 환경 변수 형식 지원)
|
||||
$this->redis = [
|
||||
'host' => env('redis.default.host', '127.0.0.1'),
|
||||
'password' => (env('redis.default.password') === '' || env('redis.default.password') === null) ? null : env('redis.default.password'),
|
||||
'port' => (int)env('redis.default.port', 6379),
|
||||
'timeout' => (int)env('redis.default.timeout', 0),
|
||||
'database' => (int)env('redis.default.database', 0)
|
||||
'host' => env('REDIS_HOST', env('redis.default.host', '127.0.0.1')),
|
||||
'password' => env('REDIS_PASSWORD', env('redis.default.password')) ?: null,
|
||||
'port' => (int)(env('REDIS_PORT', env('redis.default.port', 6379))),
|
||||
'timeout' => (int)(env('REDIS_TIMEOUT', env('redis.default.timeout', 0))),
|
||||
'database' => (int)(env('REDIS_DATABASE', env('redis.default.database', 0)))
|
||||
];
|
||||
|
||||
// 필요하다면, 이 생성자에서 $handler나 $backupHandler 같은 다른 설정도
|
||||
|
||||
Reference in New Issue
Block a user