Files
michaelschiemer/tests/debug/debug-filequeue-pop.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

116 lines
3.5 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
require_once __DIR__ . '/../bootstrap.php';
use App\Framework\Filesystem\FileStorage;
use App\Framework\Queue\FileQueue;
use App\Framework\Queue\ValueObjects\JobPayload;
use App\Framework\Queue\ValueObjects\QueuePriority;
use App\Framework\Serializer\Php\PhpSerializer;
// Simple test job class
class PopDebugJob
{
public function __construct(
public string $id,
public string $message
) {
}
}
echo "🐛 Debug FileQueue Pop Operation\n";
echo "================================\n\n";
// Create temporary queue directory
$queuePath = __DIR__ . '/../tmp/debug_pop_' . uniqid();
mkdir($queuePath, 0777, true);
$storage = new FileStorage();
$queue = new FileQueue($queuePath, storage: $storage);
// Create and push a job
$testJob = new PopDebugJob('pop-debug-1', 'Test pop debug message');
$payload = JobPayload::create($testJob, QueuePriority::normal());
echo "1⃣ Created payload and pushing...\n";
$queue->push($payload);
echo "2⃣ Push completed, queue size: " . $queue->size() . "\n";
// Manual debugging of the pop process
$priorityFiles = $queue->getPriorityJobFiles();
echo "3⃣ Found " . count($priorityFiles) . " priority files\n";
if (! empty($priorityFiles)) {
$firstFile = reset($priorityFiles);
echo "4⃣ First file: " . $firstFile->filename . "\n";
$priorityDir = $queuePath . '/priority';
$filePath = $priorityDir . '/' . $firstFile->filename;
echo "5⃣ Full file path: {$filePath}\n";
// Try to read content
try {
$content = $storage->get($filePath);
echo "6⃣ Read content, length: " . strlen($content) . " bytes\n";
// Try to unserialize
$serializer = new PhpSerializer();
$unserializedPayload = $serializer->deserialize($content);
echo "7⃣ Unserialized payload type: " . get_class($unserializedPayload) . "\n";
if ($unserializedPayload instanceof JobPayload) {
echo "8⃣ Payload is JobPayload instance ✅\n";
echo "9⃣ Job type: " . get_class($unserializedPayload->job) . "\n";
echo "🔟 Job ID: " . $unserializedPayload->job->id . "\n";
} else {
echo "8⃣ Payload is NOT JobPayload instance ❌\n";
echo " Actual type: " . get_class($unserializedPayload) . "\n";
}
} catch (\Throwable $e) {
echo "6⃣ Error reading/unserializing: " . $e->getMessage() . "\n";
echo " Exception type: " . get_class($e) . "\n";
echo " Stack trace:\n" . $e->getTraceAsString() . "\n";
}
}
// Now try the actual pop
echo "\n🔄 Now trying actual pop...\n";
try {
$poppedPayload = $queue->pop();
if ($poppedPayload !== null) {
echo "1⃣1⃣ Pop successful! Job ID: " . $poppedPayload->job->id . "\n";
} else {
echo "1⃣1⃣ Pop returned null ❌\n";
}
} catch (\Throwable $e) {
echo "1⃣1⃣ Pop threw exception: " . $e->getMessage() . "\n";
echo " Exception type: " . get_class($e) . "\n";
}
echo "1⃣2⃣ Final queue size: " . $queue->size() . "\n";
// Cleanup
function deleteDirectory($dir)
{
if (! is_dir($dir)) {
return;
}
$files = array_diff(scandir($dir), ['.', '..']);
foreach ($files as $file) {
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
deleteDirectory($path);
} else {
unlink($path);
}
}
rmdir($dir);
}
deleteDirectory($queuePath);
echo "1⃣3⃣ Cleanup completed\n";