From 696e2b52355b32608f65315bb6c079ce8890e8d4 Mon Sep 17 00:00:00 2001 From: myrmidex Date: Sat, 9 Aug 2025 15:22:56 +0200 Subject: [PATCH] Fix automatic article discovery --- backend/app/Jobs/ArticleDiscoveryJob.php | 7 +++++-- backend/bootstrap/app.php | 11 +++++++++++ backend/config/horizon.php | 2 +- docker/dev/podman/start-dev.sh | 15 +++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/backend/app/Jobs/ArticleDiscoveryJob.php b/backend/app/Jobs/ArticleDiscoveryJob.php index 5ea8476..adf58ce 100644 --- a/backend/app/Jobs/ArticleDiscoveryJob.php +++ b/backend/app/Jobs/ArticleDiscoveryJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Models\Feed; use App\Models\Setting; use App\Services\Log\LogSaver; use Illuminate\Contracts\Queue\ShouldQueue; @@ -20,14 +21,16 @@ public function handle(): void { if (!Setting::isArticleProcessingEnabled()) { LogSaver::info('Article processing is disabled. Article discovery skipped.'); + return; + } + if (!Feed::where('is_active', true)->exists()) { + LogSaver::info('No active feeds found. Article discovery skipped.'); return; } LogSaver::info('Starting article discovery for all active feeds'); - ArticleDiscoveryForFeedJob::dispatchForAllActiveFeeds(); - LogSaver::info('Article discovery jobs dispatched for all active feeds'); } } diff --git a/backend/bootstrap/app.php b/backend/bootstrap/app.php index b08c378..642c928 100644 --- a/backend/bootstrap/app.php +++ b/backend/bootstrap/app.php @@ -2,6 +2,7 @@ use App\Http\Middleware\HandleAppearance; use App\Http\Middleware\HandleInertiaRequests; +use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; @@ -23,6 +24,16 @@ AddLinkHeadersForPreloadedAssets::class, ]); }) + ->withSchedule(function (Schedule $schedule) { + $schedule->command('article:refresh') + ->everyFifteenMinutes() + ->when(function () { + return \App\Models\Setting::isArticleProcessingEnabled() + && \App\Models\Feed::where('is_active', true)->exists(); + }) + ->withoutOverlapping() + ->onOneServer(); + }) ->withExceptions(function (Exceptions $exceptions) { $exceptions->reportable(function (Throwable $e) { $level = match (true) { diff --git a/backend/config/horizon.php b/backend/config/horizon.php index cf9d5cf..c53d505 100644 --- a/backend/config/horizon.php +++ b/backend/config/horizon.php @@ -182,7 +182,7 @@ 'defaults' => [ 'supervisor-1' => [ 'connection' => 'redis', - 'queue' => ['default', 'lemmy-posts', 'lemmy-publish'], + 'queue' => ['default', 'lemmy-posts', 'lemmy-publish', 'feed-discovery'], 'balance' => 'auto', 'autoScalingStrategy' => 'time', 'maxProcesses' => 1, diff --git a/docker/dev/podman/start-dev.sh b/docker/dev/podman/start-dev.sh index 00c9060..55f455f 100755 --- a/docker/dev/podman/start-dev.sh +++ b/docker/dev/podman/start-dev.sh @@ -53,6 +53,21 @@ else echo "âš ī¸ Vite dev server may not have started properly" fi +# Check Laravel Horizon status inside the app container +echo "🔍 Checking Laravel Horizon in app container..." +HSTATUS="$(podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:status" 2>/dev/null || echo "Horizon status: unknown")" +echo "$HSTATUS" +if echo "$HSTATUS" | grep -qi 'inactive'; then + echo "â„šī¸ Horizon is inactive. Attempting to start..." + podman exec -d ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon > /dev/null 2>&1 &" || true + sleep 2 + podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:status" || true +else + echo "✅ Horizon appears to be running." +fi +# Show supervisors summary (non-fatal if unavailable) +podman exec ffr-dev-app bash -lc "cd /var/www/html/backend && php artisan horizon:supervisors | sed -n '1,80p'" || true + echo "✅ Development environment is ready!" echo "🌐 Application: http://localhost:8000" echo "đŸ”Ĩ Vite dev server: http://localhost:5173"