feat: cleanup unreachable servers

This commit is contained in:
Andras Bacsai 2024-01-30 10:50:54 +01:00
parent 9667cd4a7a
commit bb05058dda
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
<?php
namespace App\Console\Commands;
use App\Models\Server;
use Illuminate\Console\Command;
class CleanupUnreachableServers extends Command
{
protected $signature = 'cleanup:unreachable-servers';
protected $description = 'Cleanup Unreachable Servers (3 days)';
public function handle()
{
echo "Running unreachable server cleanup...\n";
$servers = Server::where('unreachable_count', 3)->where('unreachable_notification_sent', true)->where('updated_at', '<', now()->subDays(3))->get();
if ($servers->count() > 0) {
foreach ($servers as $server) {
ray('Cleanup unreachable server', $server->id);
// $server->update([
// 'ip' => '1.2.3.4'
// ]);
}
}
}
}

View File

@ -36,6 +36,7 @@ protected function schedule(Schedule $schedule): void
} else {
// Instance Jobs
$schedule->command('horizon:snapshot')->everyFiveMinutes();
// $schedule->command('cleanup:unreachable-servers')->daily();
$schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
// $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer();