Update task scheduler, add weekly instance scan to check nodeinfo for known instances

This commit is contained in:
Daniel Supernault 2024-05-31 02:56:13 -06:00
parent bcea2f05f5
commit dc6b9f4661
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
2 changed files with 49 additions and 2 deletions

View file

@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Instance;
use App\Jobs\InstancePipeline\FetchNodeinfoPipeline;
use Illuminate\Console\Command;
use function Laravel\Prompts\progress;
class WeeklyInstanceScan extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:weekly-instance-scan';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Scan instance nodeinfo';
/**
* Execute the console command.
*/
public function handle()
{
if ((bool) config_cache('federation.activitypub.enabled') == false) {
return;
}
$users = progress(
label: 'Updating instance stats...',
steps: Instance::all(),
callback: fn ($instance) => $this->updateInstanceStats($instance),
);
}
protected function updateInstanceStats($instance)
{
FetchNodeinfoPipeline::dispatch($instance)->onQueue('intbg');
}
}

View file

@ -19,7 +19,6 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
@ -32,6 +31,7 @@ class Kernel extends ConsoleKernel
$schedule->command('gc:failedjobs')->dailyAt(3)->onOneServer();
$schedule->command('gc:passwordreset')->dailyAt('09:41')->onOneServer();
$schedule->command('gc:sessions')->twiceDaily(13, 23)->onOneServer();
$schedule->command('app:weekly-instance-scan')->weeklyOn(2, '4:20')->onOneServer();
if ((bool) config_cache('pixelfed.cloud_storage') && (bool) config_cache('media.delete_local_after_cloud')) {
$schedule->command('media:s3gc')->hourlyAt(15);
@ -60,7 +60,7 @@ class Kernel extends ConsoleKernel
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}