Fix automatic article discovery

This commit is contained in:
myrmidex 2025-08-09 15:22:56 +02:00
parent 2a68895ba9
commit 696e2b5235
4 changed files with 32 additions and 3 deletions

View file

@ -2,6 +2,7 @@
namespace App\Jobs; namespace App\Jobs;
use App\Models\Feed;
use App\Models\Setting; use App\Models\Setting;
use App\Services\Log\LogSaver; use App\Services\Log\LogSaver;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
@ -20,14 +21,16 @@ public function handle(): void
{ {
if (!Setting::isArticleProcessingEnabled()) { if (!Setting::isArticleProcessingEnabled()) {
LogSaver::info('Article processing is disabled. Article discovery skipped.'); 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; return;
} }
LogSaver::info('Starting article discovery for all active feeds'); LogSaver::info('Starting article discovery for all active feeds');
ArticleDiscoveryForFeedJob::dispatchForAllActiveFeeds(); ArticleDiscoveryForFeedJob::dispatchForAllActiveFeeds();
LogSaver::info('Article discovery jobs dispatched for all active feeds'); LogSaver::info('Article discovery jobs dispatched for all active feeds');
} }
} }

View file

@ -2,6 +2,7 @@
use App\Http\Middleware\HandleAppearance; use App\Http\Middleware\HandleAppearance;
use App\Http\Middleware\HandleInertiaRequests; use App\Http\Middleware\HandleInertiaRequests;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Application; use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware; use Illuminate\Foundation\Configuration\Middleware;
@ -23,6 +24,16 @@
AddLinkHeadersForPreloadedAssets::class, 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) { ->withExceptions(function (Exceptions $exceptions) {
$exceptions->reportable(function (Throwable $e) { $exceptions->reportable(function (Throwable $e) {
$level = match (true) { $level = match (true) {

View file

@ -182,7 +182,7 @@
'defaults' => [ 'defaults' => [
'supervisor-1' => [ 'supervisor-1' => [
'connection' => 'redis', 'connection' => 'redis',
'queue' => ['default', 'lemmy-posts', 'lemmy-publish'], 'queue' => ['default', 'lemmy-posts', 'lemmy-publish', 'feed-discovery'],
'balance' => 'auto', 'balance' => 'auto',
'autoScalingStrategy' => 'time', 'autoScalingStrategy' => 'time',
'maxProcesses' => 1, 'maxProcesses' => 1,

View file

@ -53,6 +53,21 @@ else
echo "⚠️ Vite dev server may not have started properly" echo "⚠️ Vite dev server may not have started properly"
fi 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 "✅ Development environment is ready!"
echo "🌐 Application: http://localhost:8000" echo "🌐 Application: http://localhost:8000"
echo "🔥 Vite dev server: http://localhost:5173" echo "🔥 Vite dev server: http://localhost:5173"