Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -0,0 +1,134 @@
<?php
declare(strict_types=1);
namespace App\Framework\Redis;
use Redis;
use RedisException;
/**
* Managed Redis connection with health checking and reconnection using php-redis extension
*/
final class RedisConnection implements RedisConnectionInterface
{
private Redis $client;
private bool $connected = false;
public function __construct(
private readonly RedisConfig $config,
private readonly string $name = 'default'
) {
$this->connect();
}
public function getClient(): Redis
{
if (! $this->isConnected()) {
$this->reconnect();
}
return $this->client;
}
public function getDatabase(): int
{
return $this->config->database;
}
public function getName(): string
{
return $this->name;
}
public function isConnected(): bool
{
if (! $this->connected) {
return false;
}
try {
return $this->client->ping() === '+PONG';
} catch (RedisException) {
$this->connected = false;
return false;
}
}
public function reconnect(): void
{
$this->connected = false;
$this->connect();
}
private function connect(): void
{
if (! extension_loaded('redis')) {
throw new RedisConnectionException(
"Redis extension is not loaded. Please install php-redis extension or use alternative cache drivers."
);
}
$this->client = new Redis();
try {
// Connect to Redis
$success = $this->client->connect(
$this->config->host,
$this->config->port,
$this->config->timeout,
null, // reserved
0, // retry_interval
$this->config->readWriteTimeout
);
if (! $success) {
throw new RedisConnectionException("Failed to connect to Redis server");
}
// Authenticate if password is provided
if ($this->config->password) {
if (! $this->client->auth($this->config->password)) {
throw new RedisConnectionException("Redis authentication failed");
}
}
// Select database
if ($this->config->database > 0) {
if (! $this->client->select($this->config->database)) {
throw new RedisConnectionException("Failed to select Redis database {$this->config->database}");
}
}
// Set additional options
foreach ($this->config->options as $option => $value) {
$this->client->setOption($option, $value);
}
$this->connected = true;
} catch (RedisException $e) {
$this->connected = false;
throw new RedisConnectionException(
"Failed to connect to Redis ({$this->name}): " . $e->getMessage(),
previous: $e
);
}
}
/**
* Close the connection when the object is destroyed
*/
public function __destruct()
{
if ($this->connected && $this->client) {
try {
$this->client->close();
} catch (RedisException) {
// Ignore disconnection errors during destruction
}
}
}
}