mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-16 01:32:39 -04:00
High disk usage notifications were sent every ~10 minutes on Coolify Cloud because the cache rate limiter did not hold across Sentinel-triggered checks. - Add a notification_throttles table and NotificationThrottle helper that atomically records when a notification was sent for a resource. - Add the ThrottledNotification contract; Team::notify() skips a throttled notification that was already sent within its interval. - High disk usage: configurable per-server interval (server_disk_usage_notification_interval_hours, default 24h) in Server > Advanced and the servers API. - Container restarted (coolify-proxy, database TCP proxy): at most one notification per hour per server/database during a restart loop. - Move the unreachable and missing-backup markers into the new table and migrate existing data (servers.unreachable_notification_sent and scheduled_database_backups.missing_backup_notification_sent_at). - Regenerate OpenAPI files.
33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\Server;
|
|
use App\Notifications\Server\Unreachable;
|
|
use Illuminate\Console\Command;
|
|
|
|
class CleanupUnreachableServers extends Command
|
|
{
|
|
protected $signature = 'cleanup:unreachable-servers';
|
|
|
|
protected $description = 'Cleanup Unreachable Servers (7 days)';
|
|
|
|
public function handle()
|
|
{
|
|
echo "Running unreachable server cleanup...\n";
|
|
$servers = Server::where('unreachable_count', '>=', 3)->whereHas('notificationThrottles', fn ($query) => $query->where('notification', Unreachable::class))->where('updated_at', '<', now()->subDays(7))->get();
|
|
if ($servers->count() > 0) {
|
|
foreach ($servers as $server) {
|
|
echo "Cleanup unreachable server ($server->id) with name $server->name";
|
|
if (isCloud()) {
|
|
$server->update([
|
|
'ip' => '1.2.3.4',
|
|
]);
|
|
} else {
|
|
$server->forceDisableServer();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|