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.

rename to docker cleanup and and feedback implementation

ayntk-ai012c23586d5f
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 252d23021c..073f5898d7 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -29,8 +29,6 @@ class Kernel extends ConsoleKernel
{
$this->all_servers = Server::all();
$settings = InstanceSettings::get();
- $mainServer = Server::find(0);
- $serverSettings = $mainServer->settings;
if (isDev()) {
// Instance Jobs
@@ -44,10 +42,10 @@ class Kernel extends ConsoleKernel
} else {
// Instance Jobs
$schedule->command('horizon:snapshot')->everyFiveMinutes();
- $schedule->command('cleanup:unreachable-servers')->cron($serverSettings->server_cleanup_frequency)->onOneServer();
+ $schedule->command('cleanup:unreachable-servers')->daily()->onOneServer();
$schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer();
$schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer();
- $schedule->job(new CleanupInstanceStuffsJob)->cron($serverSettings->server_cleanup_frequency)->onOneServer();
+ $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer();
$this->schedule_updates($schedule);
// Server Jobs
@@ -57,7 +55,7 @@ class Kernel extends ConsoleKernel
$this->check_scheduled_tasks($schedule);
$schedule->command('cleanup:database --yes')->daily();
- $schedule->command('uploads:clear')->cron($serverSettings->server_cleanup_frequency)->onOneServer();
+ $schedule->command('uploads:clear')->everyTwoMinutes();
}
}
@@ -95,9 +93,6 @@ class Kernel extends ConsoleKernel
private function check_resources($schedule)
{
- $mainServer = Server::find(0);
- $serverSettings = $mainServer->settings;
-
if (isCloud()) {
$servers = $this->all_servers->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4');
$own = Team::find(0)->servers;
@@ -107,7 +102,11 @@ class Kernel extends ConsoleKernel
}
foreach ($servers as $server) {
$schedule->job(new ServerCheckJob($server))->everyMinute()->onOneServer();
- $schedule->job(new DockerCleanupJob($server))->cron($serverSettings->server_cleanup_frequency)->onOneServer();
+ //The lines below need to be added as soon as timzone is merged!!
+ //$serverTimezone = $server->settings->server_timezone;
+ //$schedule->job(new DockerCleanupJob($server))->cron($server->settings->docker_cleanup_frequency)->timezone($serverTimezone)->onOneServer();
+ $schedule->job(new DockerCleanupJob($server))->cron($server->settings->docker_cleanup_frequency)->onOneServer();
+
}
}
diff --git a/app/Jobs/DockerCleanupJob.php b/app/Jobs/DockerCleanupJob.php
index 9736ed0260..a44d283ced 100644
--- a/app/Jobs/DockerCleanupJob.php
+++ b/app/Jobs/DockerCleanupJob.php
@@ -29,7 +29,7 @@ class DockerCleanupJob implements ShouldBeEncrypted, ShouldQueue
if (! $this->server->isFunctional()) {
return;
}
- if ($this->server->settings->is_force_cleanup_enabled) {
+ if ($this->server->settings->force_docker_cleanup) {
Log::info('DockerCleanupJob force cleanup on ' . $this->server->name);
CleanupDocker::run(server: $this->server, force: true);
@@ -60,4 +60,4 @@ class DockerCleanupJob implements ShouldBeEncrypted, ShouldQueue
throw $e;
}
}
-}
+}
\ No newline at end of file
diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php
index 1e959ae0b2..2c96a4f162 100644
--- a/app/Livewire/Server/Form.php
+++ b/app/Livewire/Server/Form.php
@@ -45,9 +45,9 @@ class Form extends Component
'server.settings.metrics_history_days' => 'required|integer|min:1',
'wildcard_domain' => 'nullable|url',
'server.settings.is_server_api_enabled' => 'required|boolean',
- 'server.settings.force_server_cleanup' => 'required|boolean',
- 'server.settings.server_cleanup_frequency' => 'required_if:server.settings.force_server_cleanup,true|string',
- 'server.settings.server_cleanup_threshold' => 'required_if:server.settings.force_server_cleanup,false|integer|min:1|max:100',
+ 'server.settings.force_docker_cleanup' => 'required|boolean',
+ 'server.settings.docker_cleanup_frequency' => 'required_if:server.settings.force_docker_cleanup,true|string',
+ 'server.settings.docker_cleanup_threshold' => 'required_if:server.settings.force_docker_cleanup,false|integer|min:1|max:100',
];
protected $validationAttributes = [
@@ -73,17 +73,17 @@ class Form extends Component
public function mount()
{
$this->wildcard_domain = $this->server->settings->wildcard_domain;
- $this->server->settings->server_cleanup_threshold = $this->server->settings->server_cleanup_threshold;
- $this->server->settings->server_cleanup_frequency = $this->server->settings->server_cleanup_frequency;
+ $this->server->settings->docker_cleanup_threshold = $this->server->settings->docker_cleanup_threshold;
+ $this->server->settings->docker_cleanup_frequency = $this->server->settings->docker_cleanup_frequency;
}
public function updated($field)
{
- if ($field === 'server.settings.server_cleanup_frequency') {
- $frequency = $this->server->settings->server_cleanup_frequency;
+ if ($field === 'server.settings.docker_cleanup_frequency') {
+ $frequency = $this->server->settings->docker_cleanup_frequency;
if (empty($frequency) || !validate_cron_expression($frequency)) {
- $this->dispatch('error', 'Invalid Cron / Human expression for Server Cleanup Frequency. Resetting to default 10 minutes.');
- $this->server->settings->server_cleanup_frequency = '*/10 * * * *';
+ $this->dispatch('error', 'Invalid Cron / Human expression for Docker Cleanup Frequency. Resetting to default 10 minutes.');
+ $this->server->settings->docker_cleanup_frequency = '*/10 * * * *';
}
}
}
diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php
index 1521fab3f2..6ef7f46eef 100644
--- a/app/Models/ServerSetting.php
+++ b/app/Models/ServerSetting.php
@@ -37,8 +37,8 @@ use OpenApi\Attributes as OA;
'metrics_history_days' => ['type' => 'integer'],
'metrics_refresh_rate_seconds' => ['type' => 'integer'],
'metrics_token' => ['type' => 'string'],
- 'server_cleanup_frequency' => ['type' => 'string'],
- 'server_cleanup_threshold' => ['type' => 'integer'],
+ 'docker_cleanup_frequency' => ['type' => 'string'],
+ 'docker_cleanup_threshold' => ['type' => 'integer'],
'server_id' => ['type' => 'integer'],
'wildcard_domain' => ['type' => 'string'],
'created_at' => ['type' => 'string'],
@@ -50,8 +50,8 @@ class ServerSetting extends Model
protected $guarded = [];
protected $casts = [
- 'force_server_cleanup' => 'boolean',
- 'server_cleanup_threshold' => 'integer',
+ 'force_docker_cleanup' => 'boolean',
+ 'docker_cleanup_threshold' => 'integer',
];
public function server()
diff --git a/database/migrations/2024_08_09_215659_add_server_cleanup_fields_to_server_settings_table.php b/database/migrations/2024_08_09_215659_add_server_cleanup_fields_to_server_settings_table.php
index b1c1881e9b..4e1bfb3577 100644
--- a/database/migrations/2024_08_09_215659_add_server_cleanup_fields_to_server_settings_table.php
+++ b/database/migrations/2024_08_09_215659_add_server_cleanup_fields_to_server_settings_table.php
@@ -14,9 +14,9 @@ class AddServerCleanupFieldsToServerSettingsTable extends Migration
public function up()
{
Schema::table('server_settings', function (Blueprint $table) {
- $table->boolean('force_server_cleanup')->default(false);
- $table->string('server_cleanup_frequency')->default('*/10 * * * *');
- $table->integer('server_cleanup_threshold')->default(80);
+ $table->boolean('force_docker_cleanup')->default(false);
+ $table->string('docker_cleanup_frequency')->default('*/10 * * * *');
+ $table->integer('docker_cleanup_threshold')->default(80);
// Remove old columns
@@ -33,9 +33,9 @@ class AddServerCleanupFieldsToServerSettingsTable extends Migration
public function down()
{
Schema::table('server_settings', function (Blueprint $table) {
- $table->dropColumn('force_server_cleanup');
- $table->dropColumn('server_cleanup_frequency');
- $table->dropColumn('server_cleanup_threshold');
+ $table->dropColumn('force_docker_cleanup');
+ $table->dropColumn('docker_cleanup_frequency');
+ $table->dropColumn('docker_cleanup_threshold');
// Add back old columns
diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php
index 5408ab2b46..ee8855321e 100644
--- a/resources/views/livewire/server/form.blade.php
+++ b/resources/views/livewire/server/form.blade.php
@@ -126,12 +126,11 @@
<div class="flex flex-col gap-2">
<div class="flex flex-col flex-wrap gap-2 sm:flex-nowrap">
<div class="w-64">
- <x-forms.checkbox helper="Enable force Server Cleanup. This will cleanup build caches / unused images / other docker things, unreachebale servers and uploads" instantSave id="server.settings.force_server_cleanup" label="Force Server Cleanup" />
- </div>
- @if ($server->settings->force_server_cleanup)
- <x-forms.input placeholder="*/10 * * * *" id="server.settings.server_cleanup_frequency" label="Server Cleanup Frequency" required helper="Cron expression for Server Cleanup.<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every 10 minutes." />
+ <x-forms.checkbox helper="Enable force Docker Cleanup. This will cleanup build caches / unused images / etc." instantSave id="server.settings.force_docker_cleanup" label="Force Docker Cleanup" /> </div>
+ @if ($server->settings->force_docker_cleanup)
+ <x-forms.input placeholder="*/10 * * * *" id="server.settings.docker_cleanup_frequency" label="Docker Cleanup Frequency" required helper="Cron expression for Docker Cleanup.<br>You can use every_minute, hourly, daily, weekly, monthly, yearly.<br><br>Default is every 10 minutes." />
@else
- <x-forms.input id="server.settings.server_cleanup_threshold" label="Server cleanup threshold (%)" required helper="The Server cleanup tasks will run when the disk usage exceeds this threshold." />
+ <x-forms.input id="server.settings.docker_cleanup_threshold" label="Docker cleanup threshold (%)" required helper="The Docker cleanup tasks will run when the disk usage exceeds this threshold." />
@endif
</div>
<div class="flex flex-wrap gap-2 sm:flex-nowrap">