mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-15 09:12:32 -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.
102 lines
3.9 KiB
PHP
102 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Server;
|
|
|
|
use App\Models\Server;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
|
|
class Advanced extends Component
|
|
{
|
|
public Server $server;
|
|
|
|
public array $parameters = [];
|
|
|
|
#[Validate(['string'])]
|
|
public string $serverDiskUsageCheckFrequency = '0 23 * * *';
|
|
|
|
#[Validate(['required', 'integer', 'min:1', 'max:99'])]
|
|
public int|string $serverDiskUsageNotificationThreshold = 50;
|
|
|
|
#[Validate(['required', 'integer', 'min:1', 'max:720'])]
|
|
public int|string $serverDiskUsageNotificationIntervalHours = 24;
|
|
|
|
#[Validate(['required', 'integer', 'min:1'])]
|
|
public int|string $concurrentBuilds = 1;
|
|
|
|
#[Validate(['required', 'integer', 'min:1'])]
|
|
public int|string $dynamicTimeout = 1;
|
|
|
|
#[Validate(['required', 'integer', 'min:1'])]
|
|
public int|string $deploymentQueueLimit = 25;
|
|
|
|
#[Validate(['required', 'integer', 'in:25,50,75,100'])]
|
|
public int|string $backupCompressionCpuPercentage = 25;
|
|
|
|
public function mount(string $server_uuid)
|
|
{
|
|
try {
|
|
$this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail();
|
|
$this->parameters = get_route_parameters();
|
|
$this->syncData();
|
|
|
|
} catch (\Throwable) {
|
|
return redirect()->route('server.index');
|
|
}
|
|
}
|
|
|
|
private function syncData(bool $toModel = false): void
|
|
{
|
|
if ($toModel) {
|
|
$this->validate();
|
|
$this->server->settings->concurrent_builds = $this->concurrentBuilds;
|
|
$this->server->settings->dynamic_timeout = $this->dynamicTimeout;
|
|
$this->server->settings->deployment_queue_limit = $this->deploymentQueueLimit;
|
|
$this->server->settings->backup_compression_cpu_percentage = $this->backupCompressionCpuPercentage;
|
|
$this->server->settings->server_disk_usage_notification_threshold = $this->serverDiskUsageNotificationThreshold;
|
|
$this->server->settings->server_disk_usage_check_frequency = $this->serverDiskUsageCheckFrequency;
|
|
$this->server->settings->server_disk_usage_notification_interval_hours = $this->serverDiskUsageNotificationIntervalHours;
|
|
$this->server->settings->save();
|
|
} else {
|
|
$this->concurrentBuilds = $this->server->settings->concurrent_builds;
|
|
$this->dynamicTimeout = $this->server->settings->dynamic_timeout;
|
|
$this->deploymentQueueLimit = $this->server->settings->deployment_queue_limit;
|
|
$this->backupCompressionCpuPercentage = $this->server->settings->backup_compression_cpu_percentage;
|
|
$this->serverDiskUsageNotificationThreshold = $this->server->settings->server_disk_usage_notification_threshold;
|
|
$this->serverDiskUsageCheckFrequency = $this->server->settings->server_disk_usage_check_frequency;
|
|
$this->serverDiskUsageNotificationIntervalHours = $this->server->settings->server_disk_usage_notification_interval_hours;
|
|
}
|
|
}
|
|
|
|
public function instantSave()
|
|
{
|
|
try {
|
|
$this->authorize('update', $this->server);
|
|
$this->syncData(true);
|
|
$this->dispatch('success', 'Server updated.');
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function submit()
|
|
{
|
|
try {
|
|
if (! validate_cron_expression($this->serverDiskUsageCheckFrequency)) {
|
|
$this->serverDiskUsageCheckFrequency = $this->server->settings->getOriginal('server_disk_usage_check_frequency');
|
|
throw new \Exception('Invalid Cron / Human expression for Disk Usage Check Frequency.');
|
|
}
|
|
$this->authorize('update', $this->server);
|
|
$this->syncData(true);
|
|
$this->dispatch('success', 'Server updated.');
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.server.advanced');
|
|
}
|
|
}
|