Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: cleanup unreachable servers

Andras Bacsaibb05058dda97
diff --git a/app/Console/Commands/CleanupUnreachableServers.php b/app/Console/Commands/CleanupUnreachableServers.php
new file mode 100644
index 0000000000..d94ceeb9c1
--- /dev/null
+++ b/app/Console/Commands/CleanupUnreachableServers.php
@@ -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'
+ // ]);
+ }
+ }
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 50db6d681c..79f8f38e49 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -36,6 +36,7 @@ class Kernel extends ConsoleKernel
} 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();