Files
michaelschiemer/tests/debug/debug-filequeue-step-by-step.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

118 lines
3.2 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;
// Simple test job class
class DebugJob
{
public function __construct(
public string $id,
public string $message
) {
}
}
echo "🐛 Debug FileQueue Step by Step\n";
echo "==============================\n\n";
// Create temporary queue directory
$queuePath = __DIR__ . '/../tmp/debug_queue_' . uniqid();
mkdir($queuePath, 0777, true);
$storage = new FileStorage();
$queue = new FileQueue($queuePath, storage: $storage);
echo "1⃣ Queue created, path: {$queuePath}\n";
// Check if directories were created
$priorityDir = $queuePath . '/priority';
$delayedDir = $queuePath . '/delayed';
echo "2⃣ Priority dir exists: " . (is_dir($priorityDir) ? "" : "") . "\n";
echo "3⃣ Delayed dir exists: " . (is_dir($delayedDir) ? "" : "") . "\n";
// Create a simple job
$testJob = new DebugJob('debug-1', 'Test debug message');
$payload = JobPayload::create($testJob, QueuePriority::normal());
echo "4⃣ Created payload with job ID: {$testJob->id}\n";
// Push the job
try {
$queue->push($payload);
echo "5⃣ Push completed successfully\n";
} catch (\Throwable $e) {
echo "5⃣ Push failed: " . $e->getMessage() . "\n";
exit(1);
}
// Check queue size
$size = $queue->size();
echo "6⃣ Queue size after push: {$size}\n";
// Check what files exist
$priorityFiles = $queue->getPriorityJobFiles();
echo "7⃣ Priority files count: " . count($priorityFiles) . "\n";
if (! empty($priorityFiles)) {
echo "8⃣ First file: " . $priorityFiles[0]->filename . "\n";
// Try to read the file manually
$filePath = $priorityDir . '/' . $priorityFiles[0]->filename;
echo "9⃣ File path: {$filePath}\n";
echo "🔟 File exists: " . (file_exists($filePath) ? "" : "") . "\n";
if (file_exists($filePath)) {
$content = file_get_contents($filePath);
echo "1⃣1⃣ File content length: " . strlen($content) . " bytes\n";
echo "1⃣2⃣ Content preview: " . substr($content, 0, 100) . "...\n";
}
}
// Try to pop
echo "\n🔄 Attempting to pop...\n";
try {
$poppedPayload = $queue->pop();
if ($poppedPayload !== null) {
echo "1⃣3⃣ Pop successful! Job ID: " . $poppedPayload->job->id . "\n";
} else {
echo "1⃣3⃣ Pop returned null\n";
}
} catch (\Throwable $e) {
echo "1⃣3⃣ Pop failed: " . $e->getMessage() . "\n";
echo "Stack trace:\n" . $e->getTraceAsString() . "\n";
}
// Final queue size
$finalSize = $queue->size();
echo "1⃣4⃣ Final queue size: {$finalSize}\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⃣5⃣ Cleanup completed\n";