🚀 مُصادَق: الإطلاق الأولي للنظام المتكامل

This commit is contained in:
Hamza-Ayed
2026-05-03 00:59:39 +03:00
commit d0e538408d
43 changed files with 2554 additions and 0 deletions

43
queue/worker.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
require_once __DIR__ . '/../vendor/autoload.php';
use App\Core\Application;
use App\Services\QueueService;
// Initialize App (loads .env, etc.)
$app = new Application(dirname(__DIR__));
echo "[*] Musadaq Queue Worker Started...\n";
// Signal handling for graceful shutdown
$keepRunning = true;
pcntl_async_signals(true);
pcntl_signal(SIGTERM, function() use (&$keepRunning) {
echo "[!] SIGTERM received, shutting down gracefully...\n";
$keepRunning = false;
});
while ($keepRunning) {
$job = QueueService::pop();
if ($job) {
echo "[+] Processing job: {$job['type']} ({$job['id']})\n";
try {
// Process based on type
// match($job['type']) { ... }
echo "[✓] Job completed: {$job['id']}\n";
} catch (\Throwable $e) {
echo "[✗] Job failed: {$job['id']} - {$e->getMessage()}\n";
// Handle retries or DLQ
}
} else {
// Sleep if no jobs
usleep(500000); // 0.5s
}
}
echo "[*] Worker stopped.\n";