diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.php index 3274566a1..8dca584f2 100644 --- a/app/Actions/Database/StartMariadb.php +++ b/app/Actions/Database/StartMariadb.php @@ -71,7 +71,7 @@ public function handle(StandaloneMariadb $database) if (!is_null($this->database->limits_cpuset)) { data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } - if ($this->database->destination->server->is_log_drain_enabled() && $this->database->is_log_drain_enabled()) { + if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.php index 75bfe3ed3..ef04a9be8 100644 --- a/app/Actions/Database/StartMongodb.php +++ b/app/Actions/Database/StartMongodb.php @@ -78,7 +78,7 @@ public function handle(StandaloneMongodb $database) if (!is_null($this->database->limits_cpuset)) { data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } - if ($this->database->destination->server->is_log_drain_enabled() && $this->database->is_log_drain_enabled()) { + if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.php index 4a8edc1e2..3b47483a3 100644 --- a/app/Actions/Database/StartMysql.php +++ b/app/Actions/Database/StartMysql.php @@ -71,7 +71,7 @@ public function handle(StandaloneMysql $database) if (!is_null($this->database->limits_cpuset)) { data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } - if ($this->database->destination->server->is_log_drain_enabled() && $this->database->is_log_drain_enabled()) { + if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.php index ea5de10da..844f81c31 100644 --- a/app/Actions/Database/StartPostgresql.php +++ b/app/Actions/Database/StartPostgresql.php @@ -77,7 +77,7 @@ public function handle(StandalonePostgresql $database) if (!is_null($this->database->limits_cpuset)) { data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } - if ($this->database->destination->server->is_log_drain_enabled() && $this->database->is_log_drain_enabled()) { + if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { ray('Log Drain Enabled'); $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.php index 692c14c1c..e1a8eef41 100644 --- a/app/Actions/Database/StartRedis.php +++ b/app/Actions/Database/StartRedis.php @@ -81,7 +81,7 @@ public function handle(StandaloneRedis $database) if (!is_null($this->database->limits_cpuset)) { data_set($docker_compose, "services.{$container_name}.cpuset", $this->database->limits_cpuset); } - if ($this->database->destination->server->is_log_drain_enabled() && $this->database->is_log_drain_enabled()) { + if ($this->database->destination->server->isLogDrainEnabled() && $this->database->isLogDrainEnabled()) { $docker_compose['services'][$container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4599dd5a4..e92c602cf 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -77,7 +77,7 @@ private function check_resources($schedule) // ray('dispatching container status job in ' . $randomSeconds . ' seconds'); // dispatch($job); // })->name('container-status-' . $server->id)->everyMinute()->onOneServer(); - if ($server->is_log_drain_enabled()) { + if ($server->isLogDrainEnabled()) { $schedule->job(new CheckLogDrainContainerJob($server))->everyMinute()->onOneServer(); // $schedule // ->call(function () use ($server) { diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 29709d675..0dedfd596 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -1185,7 +1185,7 @@ private function generate_compose_file() } else { $docker_compose['services'][$this->container_name]['labels'] = $labels; } - if ($this->server->is_log_drain_enabled() && $this->application->is_log_drain_enabled()) { + if ($this->server->isLogDrainEnabled() && $this->application->isLogDrainEnabled()) { $docker_compose['services'][$this->container_name]['logging'] = [ 'driver' => 'fluentd', 'options' => [ diff --git a/app/Livewire/Project/Application/Advanced.php b/app/Livewire/Project/Application/Advanced.php index 442f5488a..278cab5a1 100644 --- a/app/Livewire/Project/Application/Advanced.php +++ b/app/Livewire/Project/Application/Advanced.php @@ -29,14 +29,14 @@ class Advanced extends Component 'application.settings.gpu_options' => 'string|required', ]; public function mount() { - $this->is_force_https_enabled = $this->application->settings->is_force_https_enabled; - $this->is_gzip_enabled = $this->application->settings->is_gzip_enabled; - $this->is_stripprefix_enabled = $this->application->settings->is_stripprefix_enabled; + $this->is_force_https_enabled = $this->application->isForceHttpsEnabled(); + $this->is_gzip_enabled = $this->application->isGzipEnabled(); + $this->is_stripprefix_enabled = $this->application->isStripprefixEnabled(); } public function instantSave() { - if ($this->application->is_log_drain_enabled()) { - if (!$this->application->destination->server->is_log_drain_enabled()) { + if ($this->application->isLogDrainEnabled()) { + if (!$this->application->destination->server->isLogDrainEnabled()) { $this->application->settings->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on this server.'); return; diff --git a/app/Livewire/Project/Database/Mariadb/General.php b/app/Livewire/Project/Database/Mariadb/General.php index 9e0a0c5fc..a4b6e1883 100644 --- a/app/Livewire/Project/Database/Mariadb/General.php +++ b/app/Livewire/Project/Database/Mariadb/General.php @@ -53,7 +53,7 @@ public function mount() } public function instantSaveAdvanced() { try { - if (!$this->database->destination->server->is_log_drain_enabled()) { + if (!$this->database->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Database/Mongodb/General.php b/app/Livewire/Project/Database/Mongodb/General.php index 5c9f9cb47..c1b55b1e7 100644 --- a/app/Livewire/Project/Database/Mongodb/General.php +++ b/app/Livewire/Project/Database/Mongodb/General.php @@ -52,7 +52,7 @@ public function mount() public function instantSaveAdvanced() { try { - if (!$this->database->destination->server->is_log_drain_enabled()) { + if (!$this->database->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Database/Mysql/General.php b/app/Livewire/Project/Database/Mysql/General.php index f67641b31..cab11e8ce 100644 --- a/app/Livewire/Project/Database/Mysql/General.php +++ b/app/Livewire/Project/Database/Mysql/General.php @@ -54,7 +54,7 @@ public function mount() public function instantSaveAdvanced() { try { - if (!$this->database->destination->server->is_log_drain_enabled()) { + if (!$this->database->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Database/Postgresql/General.php b/app/Livewire/Project/Database/Postgresql/General.php index 102557351..3237c1be3 100644 --- a/app/Livewire/Project/Database/Postgresql/General.php +++ b/app/Livewire/Project/Database/Postgresql/General.php @@ -60,7 +60,7 @@ public function mount() } public function instantSaveAdvanced() { try { - if (!$this->database->destination->server->is_log_drain_enabled()) { + if (!$this->database->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Database/Redis/General.php b/app/Livewire/Project/Database/Redis/General.php index ee02239af..a894626b0 100644 --- a/app/Livewire/Project/Database/Redis/General.php +++ b/app/Livewire/Project/Database/Redis/General.php @@ -46,7 +46,7 @@ public function mount() } public function instantSaveAdvanced() { try { - if (!$this->database->destination->server->is_log_drain_enabled()) { + if (!$this->database->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Service/Database.php b/app/Livewire/Project/Service/Database.php index c86c54da2..8dec97852 100644 --- a/app/Livewire/Project/Service/Database.php +++ b/app/Livewire/Project/Service/Database.php @@ -36,7 +36,7 @@ public function mount() } public function instantSaveAdvanced() { - if (!$this->database->service->destination->server->is_log_drain_enabled()) { + if (!$this->database->service->destination->server->isLogDrainEnabled()) { $this->database->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php index 9a4738c9f..29bd796fd 100644 --- a/app/Livewire/Project/Service/ServiceApplicationView.php +++ b/app/Livewire/Project/Service/ServiceApplicationView.php @@ -30,7 +30,7 @@ public function instantSave() } public function instantSaveAdvanced() { - if (!$this->application->service->destination->server->is_log_drain_enabled()) { + if (!$this->application->service->destination->server->isLogDrainEnabled()) { $this->application->is_log_drain_enabled = false; $this->dispatch('error', 'Log drain is not enabled on the server. Please enable it first.'); return; diff --git a/app/Livewire/Server/LogDrains.php b/app/Livewire/Server/LogDrains.php index 605aa25b5..4eca682d4 100644 --- a/app/Livewire/Server/LogDrains.php +++ b/app/Livewire/Server/LogDrains.php @@ -54,7 +54,7 @@ public function configureLogDrain() { try { InstallLogDrain::run($this->server); - if (!$this->server->is_log_drain_enabled()) { + if (!$this->server->isLogDrainEnabled()) { $this->dispatch('serverRefresh'); $this->dispatch('success', 'Log drain service stopped.'); return; diff --git a/app/Models/Application.php b/app/Models/Application.php index 24a61eca9..8fa4979d7 100644 --- a/app/Models/Application.php +++ b/app/Models/Application.php @@ -80,15 +80,15 @@ public function is_github_based(): bool } return false; } - public function is_force_https_enabled() + public function isForceHttpsEnabled() { return data_get($this, 'settings.is_force_https_enabled', false); } - public function is_stripprefix_enabled() + public function isStripprefixEnabled() { return data_get($this, 'settings.is_stripprefix_enabled', true); } - public function is_gzip_enabled() + public function isGzipEnabled() { return data_get($this, 'settings.is_gzip_enabled', true); } @@ -493,7 +493,7 @@ public function workdir() { return application_configuration_dir() . "/{$this->uuid}"; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'settings.is_log_drain_enabled', false); } diff --git a/app/Models/Server.php b/app/Models/Server.php index 5293bdd99..4028109e2 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -405,7 +405,7 @@ public function isFunctional() { return $this->settings->is_reachable && $this->settings->is_usable && !$this->settings->force_disabled; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return $this->settings->is_logdrain_newrelic_enabled || $this->settings->is_logdrain_highlight_enabled || $this->settings->is_logdrain_axiom_enabled || $this->settings->is_logdrain_custom_enabled; } diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php index 8a01aa50e..37f7d9c9c 100644 --- a/app/Models/ServiceApplication.php +++ b/app/Models/ServiceApplication.php @@ -19,15 +19,15 @@ protected static function booted() $service->fileStorages()->delete(); }); } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } - public function is_stripprefix_enabled() + public function isStripprefixEnabled() { return data_get($this, 'is_stripprefix_enabled', true); } - public function is_gzip_enabled() + public function isGzipEnabled() { return data_get($this, 'is_gzip_enabled', true); } diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php index c3f4cc278..9375fe807 100644 --- a/app/Models/ServiceDatabase.php +++ b/app/Models/ServiceDatabase.php @@ -17,13 +17,17 @@ protected static function booted() $service->fileStorages()->delete(); }); } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } - public function is_gzip_enabled() + public function isStripprefixEnabled() { - return true; + return data_get($this, 'is_stripprefix_enabled', true); + } + public function isGzipEnabled() + { + return data_get($this, 'is_gzip_enabled', true); } public function type() { diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php index 2f2be6757..eb465e989 100644 --- a/app/Models/StandaloneMariadb.php +++ b/app/Models/StandaloneMariadb.php @@ -100,7 +100,7 @@ public function link() } return null; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php index cb10f8f55..a8aab4e42 100644 --- a/app/Models/StandaloneMongodb.php +++ b/app/Models/StandaloneMongodb.php @@ -92,7 +92,7 @@ public function team() { return data_get($this, 'environment.project.team'); } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php index c2d2b5c6f..89155d3ec 100644 --- a/app/Models/StandaloneMysql.php +++ b/app/Models/StandaloneMysql.php @@ -105,7 +105,7 @@ public function type(): string return 'standalone-mysql'; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php index ad0dce108..0b7589e81 100644 --- a/app/Models/StandalonePostgresql.php +++ b/app/Models/StandalonePostgresql.php @@ -97,7 +97,7 @@ public function link() } return null; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php index c1b1d1390..2b623f28d 100644 --- a/app/Models/StandaloneRedis.php +++ b/app/Models/StandaloneRedis.php @@ -96,7 +96,7 @@ public function link() } return null; } - public function is_log_drain_enabled() + public function isLogDrainEnabled() { return data_get($this, 'is_log_drain_enabled', false); } diff --git a/bootstrap/helpers/docker.php b/bootstrap/helpers/docker.php index 237a12d74..5fd43daa9 100644 --- a/bootstrap/helpers/docker.php +++ b/bootstrap/helpers/docker.php @@ -400,9 +400,9 @@ function generateLabelsApplication(Application $application, ?ApplicationPreview uuid: $appUuid, domains: $domains, onlyPort: $onlyPort, - is_force_https_enabled: $application->is_force_https_enabled(), - is_gzip_enabled: $application->is_gzip_enabled(), - is_stripprefix_enabled: $application->is_stripprefix_enabled() + is_force_https_enabled: $application->isForceHttpsEnabled(), + is_gzip_enabled: $application->isGzipEnabled(), + is_stripprefix_enabled: $application->isStripprefixEnabled() )); } return $labels->all(); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 47cc57c35..9bb2c164a 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -1052,12 +1052,13 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal domains: $fqdns, is_force_https_enabled: true, serviceLabels: $serviceLabels, - is_gzip_enabled: $savedService->is_gzip_enabled(), - is_stripprefix_enabled: $savedService->is_stripprefix_enabled(), + is_gzip_enabled: $savedService->isGzipEnabled(), + is_stripprefix_enabled: $savedService->isStripprefixEnabled(), service_name: $serviceName)); + } } - if ($resource->server->is_log_drain_enabled() && $savedService->is_log_drain_enabled()) { + if ($resource->server->isLogDrainEnabled() && $savedService->isLogDrainEnabled()) { data_set($service, 'logging', [ 'driver' => 'fluentd', 'options' => [ @@ -1501,7 +1502,7 @@ function parseDockerComposeFile(Service|Application $resource, bool $isNew = fal $defaultLabels = defaultLabels($resource->id, $containerName, $pull_request_id, type: 'application'); $serviceLabels = $serviceLabels->merge($defaultLabels); - if ($server->is_log_drain_enabled() && $resource->is_log_drain_enabled()) { + if ($server->isLogDrainEnabled() && $resource->isLogDrainEnabled()) { data_set($service, 'logging', [ 'driver' => 'fluentd', 'options' => [ diff --git a/database/migrations/2024_03_04_092244_add_gzip_enabled_and_stripprefix_settings.php b/database/migrations/2024_03_04_092244_add_gzip_enabled_and_stripprefix_settings.php index 1787a07eb..5d23da60e 100644 --- a/database/migrations/2024_03_04_092244_add_gzip_enabled_and_stripprefix_settings.php +++ b/database/migrations/2024_03_04_092244_add_gzip_enabled_and_stripprefix_settings.php @@ -18,6 +18,10 @@ public function up(): void Schema::table('service_applications', function (Blueprint $table) { $table->boolean('is_stripprefix_enabled')->default(true); }); + Schema::table('service_databases', function (Blueprint $table) { + $table->boolean('is_gzip_enabled')->default(true); + $table->boolean('is_stripprefix_enabled')->default(true); + }); } /** @@ -32,5 +36,9 @@ public function down(): void Schema::table('service_applications', function (Blueprint $table) { $table->dropColumn('is_stripprefix_enabled'); }); + Schema::table('service_databases', function (Blueprint $table) { + $table->dropColumn('is_gzip_enabled'); + $table->dropColumn('is_stripprefix_enabled'); + }); } }; diff --git a/resources/views/livewire/server/log-drains.blade.php b/resources/views/livewire/server/log-drains.blade.php index 3936bf5f9..496f60369 100644 --- a/resources/views/livewire/server/log-drains.blade.php +++ b/resources/views/livewire/server/log-drains.blade.php @@ -12,7 +12,7 @@