From 7d6a8954498d46c6b5891dee59224a0936c42f2f Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:44:20 +0200 Subject: [PATCH 01/19] Updated Configuration Settings --- .../livewire/settings/configuration.blade.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index b5fb49d3e..e2f375037 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -10,23 +10,25 @@
+

Instance Settings

+

DNS Validation

+
+ +
-
- -
{{--
--}} -
-

API

+ +

API

@@ -42,6 +44,10 @@ id="is_auto_update_enabled" label="Auto Update Coolify" /> @else + @if($is_auto_update_enabled) + + @endif + @endif From 27e82f0bde5fad6d56fa64b87a8e412236100b43 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:31:41 +0200 Subject: [PATCH 02/19] implement logic, jobs and add DB migrate --- app/Console/Kernel.php | 34 +++++++++++--- app/Jobs/CheckForUpdatesJob.php | 46 +++++++++++++++++++ app/Jobs/PullCoolifyImageJob.php | 14 ++---- app/Jobs/UpdateCoolifyJob.php | 44 ++++++++++++++++++ ...n_available_to_instance_settings_table.php | 30 ++++++++++++ 5 files changed, 151 insertions(+), 17 deletions(-) create mode 100644 app/Jobs/CheckForUpdatesJob.php create mode 100644 app/Jobs/UpdateCoolifyJob.php create mode 100644 database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index c6ee39524..fdfbc8aff 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,7 @@ use App\Jobs\PullSentinelImageJob; use App\Jobs\PullTemplatesFromCDN; use App\Jobs\ScheduledTaskJob; use App\Jobs\ServerStatusJob; +use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledTask; use App\Models\Server; @@ -27,6 +28,8 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule): void { $this->all_servers = Server::all(); + $settings = InstanceSettings::get(); + if (isDev()) { // Instance Jobs $schedule->command('horizon:snapshot')->everyMinute(); @@ -42,16 +45,17 @@ class Kernel extends ConsoleKernel // Instance Jobs $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('cleanup:unreachable-servers')->daily(); - $schedule->job(new PullCoolifyImageJob)->everyTenMinutes()->onOneServer(); + $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->everyThirtyMinutes()->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); - // $schedule->job(new CheckResaleLicenseJob)->hourly()->onOneServer(); // Server Jobs - $this->check_scheduled_backups($schedule); - $this->check_resources($schedule); + $this->scheduleUpdates($schedule); $this->pull_images($schedule); + $this->check_resources($schedule); $this->check_scheduled_tasks($schedule); + $this->check_scheduled_backups($schedule); + $schedule->command('cleanup:database --yes')->daily(); $schedule->command('uploads:clear')->everyTwoMinutes(); @@ -60,12 +64,28 @@ class Kernel extends ConsoleKernel private function pull_images($schedule) { + $settings = InstanceSettings::get(); $servers = $this->all_servers->where('settings.is_usable', true)->where('settings.is_reachable', true)->where('ip', '!=', '1.2.3.4'); foreach ($servers as $server) { if ($server->isSentinelEnabled()) { - $schedule->job(new PullSentinelImageJob($server))->everyFiveMinutes()->onOneServer(); + $schedule->job(new PullSentinelImageJob($server))->cron($settings->update_check_frequency)->onOneServer(); } - $schedule->job(new PullHelperImageJob($server))->everyFiveMinutes()->onOneServer(); + $schedule->job(new PullHelperImageJob($server))->cron($settings->update_check_frequency)->onOneServer(); + } + } + + private function scheduleUpdates($schedule) + { + $settings = InstanceSettings::get(); + + // Schedule update check + if ($settings->update_check_frequency) { + $schedule->job(new CheckForUpdatesJob())->cron($settings->update_check_frequency)->onOneServer(); + } + + // Schedule auto-update + if ($settings->is_auto_update_enabled && $settings->auto_update_frequency) { + $schedule->job(new UpdateCoolifyJob())->cron($settings->auto_update_frequency)->onOneServer(); } } @@ -162,4 +182,4 @@ class Kernel extends ConsoleKernel require base_path('routes/console.php'); } -} +} \ No newline at end of file diff --git a/app/Jobs/CheckForUpdatesJob.php b/app/Jobs/CheckForUpdatesJob.php new file mode 100644 index 000000000..8141dd3fa --- /dev/null +++ b/app/Jobs/CheckForUpdatesJob.php @@ -0,0 +1,46 @@ +get('https://cdn.coollabs.io/coolify/versions.json'); + if ($response->successful()) { + $versions = $response->json(); + $latest_version = $versions['latest']; + $current_version = config('version'); + + if (version_compare($latest_version, $current_version, '>')) { + // New version available + $settings->update(['new_version_available' => true]); + // Optionally, you can trigger a notification here + } else { + $settings->update(['new_version_available' => false]); + } + } + } catch (\Throwable $e) { + // Log the error or send a notification + ray('CheckForUpdatesJob failed: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/Jobs/PullCoolifyImageJob.php b/app/Jobs/PullCoolifyImageJob.php index 253b0b9f0..9c8145b70 100644 --- a/app/Jobs/PullCoolifyImageJob.php +++ b/app/Jobs/PullCoolifyImageJob.php @@ -2,6 +2,7 @@ namespace App\Jobs; +use App\Models\InstanceSettings; use App\Models\Server; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldBeEncrypted; @@ -16,16 +17,13 @@ class PullCoolifyImageJob implements ShouldBeEncrypted, ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $timeout = 1000; - - public function __construct() {} - public function handle(): void { try { if (isDev() || isCloud()) { return; } + $settings = InstanceSettings::get(); $server = Server::findOrFail(0); $response = Http::retry(3, 1000)->get('https://cdn.coollabs.io/coolify/versions.json'); if ($response->successful()) { @@ -35,7 +33,6 @@ class PullCoolifyImageJob implements ShouldBeEncrypted, ShouldQueue $latest_version = get_latest_version_of_coolify(); instant_remote_process(["docker pull -q ghcr.io/coollabsio/coolify:{$latest_version}"], $server, false); - $settings = \App\Models\InstanceSettings::get(); $current_version = config('version'); if (! $settings->is_auto_update_enabled) { return; @@ -46,12 +43,9 @@ class PullCoolifyImageJob implements ShouldBeEncrypted, ShouldQueue if (version_compare($latest_version, $current_version, '<')) { return; } - instant_remote_process([ - 'curl -fsSL https://cdn.coollabs.io/coolify/upgrade.sh -o /data/coolify/source/upgrade.sh', - "bash /data/coolify/source/upgrade.sh $latest_version", - ], $server); + // The actual update process will be handled by the UpdateCoolifyJob } catch (\Throwable $e) { throw $e; } } -} +} \ No newline at end of file diff --git a/app/Jobs/UpdateCoolifyJob.php b/app/Jobs/UpdateCoolifyJob.php new file mode 100644 index 000000000..243e3934f --- /dev/null +++ b/app/Jobs/UpdateCoolifyJob.php @@ -0,0 +1,44 @@ +is_auto_update_enabled || !$settings->new_version_available) { + return; + } + + $server = Server::findOrFail(0); + if (!$server) { + return; + } + + UpdateCoolify::run(false); // false means it's not a manual update + + // After successful update, reset the new_version_available flag + $settings->update(['new_version_available' => false]); + + } catch (\Throwable $e) { + // Log the error or send a notification + ray('UpdateCoolifyJob failed: ' . $e->getMessage()); + } + } +} \ No newline at end of file diff --git a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php new file mode 100644 index 000000000..37cd93dc4 --- /dev/null +++ b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php @@ -0,0 +1,30 @@ +string('update_check_frequency')->nullable(); + $table->string('auto_update_frequency')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('instance_settings', function (Blueprint $table) { + $table->dropColumn('update_check_frequency'); + $table->dropColumn('auto_update_frequency'); + }); + } +}; From 38976dac12a6a6b312fa787c4ef50696c998fd02 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:05:38 +0200 Subject: [PATCH 03/19] fixes and check for valid cron expressions --- app/Actions/Server/UpdateCoolify.php | 2 - app/Console/Kernel.php | 45 ++++++++---- app/Jobs/CheckForUpdatesJob.php | 4 +- app/Jobs/PullCoolifyImageJob.php | 1 - app/Jobs/UpdateCoolifyJob.php | 19 +++-- app/Livewire/Settings/Configuration.php | 69 ++++++++++++++++++- app/Models/InstanceSettings.php | 3 + ...n_available_to_instance_settings_table.php | 4 +- .../livewire/settings/configuration.blade.php | 4 +- 9 files changed, 124 insertions(+), 27 deletions(-) diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index a945670d4..72ce80b6b 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -20,7 +20,6 @@ class UpdateCoolify { try { $settings = InstanceSettings::get(); - ray('Running InstanceAutoUpdateJob'); $this->server = Server::find(0); if (! $this->server) { return; @@ -48,7 +47,6 @@ class UpdateCoolify private function update() { if (isDev()) { - ray('Running in dev mode'); remote_process([ 'sleep 10', ], $this->server); diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index fdfbc8aff..41d821e8a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,6 +13,8 @@ use App\Jobs\PullSentinelImageJob; use App\Jobs\PullTemplatesFromCDN; use App\Jobs\ScheduledTaskJob; use App\Jobs\ServerStatusJob; +use App\Jobs\UpdateCoolifyJob; +use App\Jobs\CheckForUpdatesJob; use App\Models\InstanceSettings; use App\Models\ScheduledDatabaseBackup; use App\Models\ScheduledTask; @@ -31,10 +33,6 @@ class Kernel extends ConsoleKernel $settings = InstanceSettings::get(); if (isDev()) { - // Instance Jobs - $schedule->command('horizon:snapshot')->everyMinute(); - $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); - $schedule->job(new PullTemplatesFromCDN)->everyTwoHours()->onOneServer(); // Server Jobs $this->check_scheduled_backups($schedule); $this->check_resources($schedule); @@ -45,10 +43,16 @@ class Kernel extends ConsoleKernel // Instance Jobs $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('cleanup:unreachable-servers')->daily(); - $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); - $schedule->job(new PullTemplatesFromCDN)->everyThirtyMinutes()->onOneServer(); - $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); - + $schedule->job(new PullTemplatesFromCDN)->daily()->onOneServer(); + $schedule->job(new CleanupInstanceStuffsJob)->everyFiveMinutes()->onOneServer(); + + if ($settings->update_check_frequency && $this->isValidCronExpression($settings->update_check_frequency)) { + $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); + } else { + // Default to every 12 hours if not set or invalid + $schedule->job(new PullCoolifyImageJob)->twiceDaily()->onOneServer(); + } + // Server Jobs $this->scheduleUpdates($schedule); $this->pull_images($schedule); @@ -56,7 +60,6 @@ class Kernel extends ConsoleKernel $this->check_scheduled_tasks($schedule); $this->check_scheduled_backups($schedule); - $schedule->command('cleanup:database --yes')->daily(); $schedule->command('uploads:clear')->everyTwoMinutes(); } @@ -79,13 +82,31 @@ class Kernel extends ConsoleKernel $settings = InstanceSettings::get(); // Schedule update check - if ($settings->update_check_frequency) { + if ($settings->update_check_frequency && $this->isValidCronExpression($settings->update_check_frequency)) { $schedule->job(new CheckForUpdatesJob())->cron($settings->update_check_frequency)->onOneServer(); + } else { + // Default to every 12 hours if not set or invalid + $schedule->job(new CheckForUpdatesJob())->twiceDaily()->onOneServer(); } // Schedule auto-update - if ($settings->is_auto_update_enabled && $settings->auto_update_frequency) { - $schedule->job(new UpdateCoolifyJob())->cron($settings->auto_update_frequency)->onOneServer(); + if ($settings->is_auto_update_enabled) { + if ($settings->auto_update_frequency && $this->isValidCronExpression($settings->auto_update_frequency)) { + $schedule->job(new UpdateCoolifyJob())->cron($settings->auto_update_frequency)->onOneServer(); + } else { + // Default to every 24 hours if not set or invalid + $schedule->job(new UpdateCoolifyJob())->daily()->onOneServer(); + } + } + } + + private function isValidCronExpression($expression) + { + try { + new \Cron\CronExpression($expression); + return true; + } catch (\Exception $e) { + return false; } } diff --git a/app/Jobs/CheckForUpdatesJob.php b/app/Jobs/CheckForUpdatesJob.php index 8141dd3fa..e18e37ed6 100644 --- a/app/Jobs/CheckForUpdatesJob.php +++ b/app/Jobs/CheckForUpdatesJob.php @@ -33,14 +33,12 @@ class CheckForUpdatesJob implements ShouldBeEncrypted, ShouldQueue if (version_compare($latest_version, $current_version, '>')) { // New version available $settings->update(['new_version_available' => true]); - // Optionally, you can trigger a notification here } else { $settings->update(['new_version_available' => false]); } } } catch (\Throwable $e) { - // Log the error or send a notification - ray('CheckForUpdatesJob failed: ' . $e->getMessage()); + // Consider implementing a notification to administrators } } } \ No newline at end of file diff --git a/app/Jobs/PullCoolifyImageJob.php b/app/Jobs/PullCoolifyImageJob.php index 9c8145b70..624dc4414 100644 --- a/app/Jobs/PullCoolifyImageJob.php +++ b/app/Jobs/PullCoolifyImageJob.php @@ -43,7 +43,6 @@ class PullCoolifyImageJob implements ShouldBeEncrypted, ShouldQueue if (version_compare($latest_version, $current_version, '<')) { return; } - // The actual update process will be handled by the UpdateCoolifyJob } catch (\Throwable $e) { throw $e; } diff --git a/app/Jobs/UpdateCoolifyJob.php b/app/Jobs/UpdateCoolifyJob.php index 243e3934f..5c8e8e679 100644 --- a/app/Jobs/UpdateCoolifyJob.php +++ b/app/Jobs/UpdateCoolifyJob.php @@ -2,7 +2,6 @@ namespace App\Jobs; -use App\Actions\Server\UpdateCoolify; use App\Models\InstanceSettings; use App\Models\Server; use Illuminate\Bus\Queueable; @@ -11,6 +10,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use App\Actions\Server\UpdateCoolify; +use Illuminate\Support\Facades\Log; class UpdateCoolifyJob implements ShouldBeEncrypted, ShouldQueue { @@ -22,23 +23,31 @@ class UpdateCoolifyJob implements ShouldBeEncrypted, ShouldQueue { try { $settings = InstanceSettings::get(); - if (!$settings->is_auto_update_enabled || !$settings->new_version_available) { + if (!$settings->is_auto_update_enabled) { + Log::info('Auto-update is disabled. Skipping update check.'); + return; + } + + if (!$settings->new_version_available) { + Log::info('No new version available. Skipping update.'); return; } $server = Server::findOrFail(0); if (!$server) { + Log::error('Server not found. Cannot proceed with update.'); return; } + Log::info('Starting Coolify update process...'); UpdateCoolify::run(false); // false means it's not a manual update - // After successful update, reset the new_version_available flag $settings->update(['new_version_available' => false]); + Log::info('Coolify update completed successfully.'); } catch (\Throwable $e) { - // Log the error or send a notification - ray('UpdateCoolifyJob failed: ' . $e->getMessage()); + Log::error('UpdateCoolifyJob failed: ' . $e->getMessage()); + // Consider implementing a notification to administrators } } } \ No newline at end of file diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index 7439e112f..0d0b110b6 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -5,6 +5,7 @@ namespace App\Livewire\Settings; use App\Models\InstanceSettings as ModelsInstanceSettings; use App\Models\Server; use Livewire\Component; +use Cron\CronExpression; class Configuration extends Component { @@ -20,6 +21,10 @@ class Configuration extends Component public bool $is_api_enabled; + public ?string $auto_update_frequency; + + public ?string $update_check_frequency; + protected string $dynamic_config_path = '/data/coolify/proxy/dynamic'; protected Server $server; @@ -32,6 +37,9 @@ class Configuration extends Component 'settings.custom_dns_servers' => 'nullable', 'settings.instance_name' => 'nullable', 'settings.allowed_ips' => 'nullable', + 'settings.is_auto_update_enabled' => 'boolean', + 'auto_update_frequency' => 'nullable|string', + 'update_check_frequency' => 'required|string', ]; protected $validationAttributes = [ @@ -41,6 +49,9 @@ class Configuration extends Component 'settings.public_port_max' => 'Public port max', 'settings.custom_dns_servers' => 'Custom DNS servers', 'settings.allowed_ips' => 'Allowed IPs', + 'settings.is_auto_update_enabled' => 'Auto Update Enabled', + 'auto_update_frequency' => 'Auto Update Frequency', + 'update_check_frequency' => 'Update Check Frequency', ]; public function mount() @@ -50,6 +61,8 @@ class Configuration extends Component $this->is_registration_enabled = $this->settings->is_registration_enabled; $this->is_dns_validation_enabled = $this->settings->is_dns_validation_enabled; $this->is_api_enabled = $this->settings->is_api_enabled; + $this->auto_update_frequency = $this->settings->auto_update_frequency; + $this->update_check_frequency = $this->settings->update_check_frequency; } public function instantSave() @@ -59,6 +72,8 @@ class Configuration extends Component $this->settings->is_registration_enabled = $this->is_registration_enabled; $this->settings->is_dns_validation_enabled = $this->is_dns_validation_enabled; $this->settings->is_api_enabled = $this->is_api_enabled; + $this->settings->auto_update_frequency = $this->auto_update_frequency; + $this->settings->update_check_frequency = $this->update_check_frequency; $this->settings->save(); $this->dispatch('success', 'Settings updated!'); } @@ -76,6 +91,16 @@ class Configuration extends Component } $this->validate(); + if ($this->is_auto_update_enabled && !$this->validateCronExpression($this->auto_update_frequency)) { + $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); + return; + } + + if (!$this->validateCronExpression($this->update_check_frequency)) { + $this->dispatch('error', 'Invalid Cron / Human expression for Update Check Frequency.'); + return; + } + if ($this->settings->is_dns_validation_enabled && $this->settings->fqdn) { if (! validate_dns_entry($this->settings->fqdn, $this->server)) { $this->dispatch('error', "Validating DNS failed.

Make sure you have added the DNS records correctly.

{$this->settings->fqdn}->{$this->server->ip}

Check this documentation for further help."); @@ -99,6 +124,14 @@ class Configuration extends Component $this->settings->allowed_ips = $this->settings->allowed_ips->unique(); $this->settings->allowed_ips = $this->settings->allowed_ips->implode(','); + $this->settings->do_not_track = $this->do_not_track; + $this->settings->is_auto_update_enabled = $this->is_auto_update_enabled; + $this->settings->is_registration_enabled = $this->is_registration_enabled; + $this->settings->is_dns_validation_enabled = $this->is_dns_validation_enabled; + $this->settings->is_api_enabled = $this->is_api_enabled; + $this->settings->auto_update_frequency = $this->auto_update_frequency; + $this->settings->update_check_frequency = $this->update_check_frequency; + $this->settings->save(); $this->server->setupDynamicProxyConfiguration(); if (! $error_show) { @@ -108,4 +141,38 @@ class Configuration extends Component return handleError($e, $this); } } -} + + private function validateCronExpression($expression): bool + { + if (empty($expression)) { + return false; + } + $isValid = false; + try { + $cronExpression = new CronExpression($expression); + $isValid = $cronExpression->getNextRunDate() !== false; + } catch (\Exception $e) { + $isValid = false; + } + + if (isset(VALID_CRON_STRINGS[$expression])) { + $isValid = true; + } + + return $isValid; + } + + public function updatedAutoUpdateFrequency() + { + if (!$this->validateCronExpression($this->auto_update_frequency)) { + $this->dispatch('error', 'Invalid Cron / Human expression.'); + } + } + + public function updatedUpdateCheckFrequency() + { + if (!$this->validateCronExpression($this->update_check_frequency)) { + $this->dispatch('error', 'Invalid Cron / Human expression.'); + } + } +} \ No newline at end of file diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php index bd3c41a1f..5bd421956 100644 --- a/app/Models/InstanceSettings.php +++ b/app/Models/InstanceSettings.php @@ -18,6 +18,9 @@ class InstanceSettings extends Model implements SendsEmail 'resale_license' => 'encrypted', 'smtp_password' => 'encrypted', 'allowed_ip_ranges' => 'array', + 'is_auto_update_enabled' => 'boolean', + 'auto_update_frequency' => 'string', + 'update_check_frequency' => 'string', ]; public function fqdn(): Attribute diff --git a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php index 37cd93dc4..25c5666b8 100644 --- a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php +++ b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php @@ -12,8 +12,8 @@ return new class extends Migration public function up(): void { Schema::table('instance_settings', function (Blueprint $table) { - $table->string('update_check_frequency')->nullable(); - $table->string('auto_update_frequency')->nullable(); + $table->string('update_check_frequency')->default('0 */12 * * *')->nullable(); + $table->string('auto_update_frequency')->default('0 0 * * *')->nullable(); }); } diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index e2f375037..e9cb7267d 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -46,8 +46,10 @@ @if($is_auto_update_enabled) + @error('settings.auto_update_frequency') {{ $message }} @enderror @endif - + + @error('settings.update_check_frequency') {{ $message }} @enderror @endif From 4dfec6771c2b02de7029190db1220a99049bf7c1 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:31:06 +0200 Subject: [PATCH 04/19] added defaults, remove duplicated cron validation --- app/Console/Kernel.php | 39 ++++--------------- app/Livewire/Settings/Configuration.php | 14 +++---- ...n_available_to_instance_settings_table.php | 2 +- .../livewire/settings/configuration.blade.php | 6 +-- 4 files changed, 17 insertions(+), 44 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 41d821e8a..92a1b1618 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -45,14 +45,9 @@ class Kernel extends ConsoleKernel $schedule->command('cleanup:unreachable-servers')->daily(); $schedule->job(new PullTemplatesFromCDN)->daily()->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyFiveMinutes()->onOneServer(); - - if ($settings->update_check_frequency && $this->isValidCronExpression($settings->update_check_frequency)) { - $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); - } else { - // Default to every 12 hours if not set or invalid - $schedule->job(new PullCoolifyImageJob)->twiceDaily()->onOneServer(); - } - + $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency ?? '0 0 * * *')->onOneServer(); + $schedule->job(new CheckForUpdatesJob())->cron($settings->auto_update_frequency ?? '0 11,23 * * *')->onOneServer(); + // Server Jobs $this->scheduleUpdates($schedule); $this->pull_images($schedule); @@ -81,32 +76,12 @@ class Kernel extends ConsoleKernel { $settings = InstanceSettings::get(); - // Schedule update check - if ($settings->update_check_frequency && $this->isValidCronExpression($settings->update_check_frequency)) { - $schedule->job(new CheckForUpdatesJob())->cron($settings->update_check_frequency)->onOneServer(); - } else { - // Default to every 12 hours if not set or invalid - $schedule->job(new CheckForUpdatesJob())->twiceDaily()->onOneServer(); - } + $updateCheckFrequency = $settings->update_check_frequency ?? '0 0 * * *'; // Default to daily at 00:00 + $schedule->job(new CheckForUpdatesJob())->cron($updateCheckFrequency)->onOneServer(); - // Schedule auto-update if ($settings->is_auto_update_enabled) { - if ($settings->auto_update_frequency && $this->isValidCronExpression($settings->auto_update_frequency)) { - $schedule->job(new UpdateCoolifyJob())->cron($settings->auto_update_frequency)->onOneServer(); - } else { - // Default to every 24 hours if not set or invalid - $schedule->job(new UpdateCoolifyJob())->daily()->onOneServer(); - } - } - } - - private function isValidCronExpression($expression) - { - try { - new \Cron\CronExpression($expression); - return true; - } catch (\Exception $e) { - return false; + $autoUpdateFrequency = $settings->auto_update_frequency ?? '0 11,23 * * *'; // Default to twice daily at 11:00 and 23:00 + $schedule->job(new UpdateCoolifyJob())->cron($autoUpdateFrequency)->onOneServer(); } } diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index 0d0b110b6..2f4c77535 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -21,9 +21,9 @@ class Configuration extends Component public bool $is_api_enabled; - public ?string $auto_update_frequency; + public string $auto_update_frequency; - public ?string $update_check_frequency; + public string $update_check_frequency; protected string $dynamic_config_path = '/data/coolify/proxy/dynamic'; @@ -39,7 +39,7 @@ class Configuration extends Component 'settings.allowed_ips' => 'nullable', 'settings.is_auto_update_enabled' => 'boolean', 'auto_update_frequency' => 'nullable|string', - 'update_check_frequency' => 'required|string', + 'update_check_frequency' => 'nullable|string', ]; protected $validationAttributes = [ @@ -91,6 +91,7 @@ class Configuration extends Component } $this->validate(); + // Allow empty values and set defaults if ($this->is_auto_update_enabled && !$this->validateCronExpression($this->auto_update_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); return; @@ -131,7 +132,6 @@ class Configuration extends Component $this->settings->is_api_enabled = $this->is_api_enabled; $this->settings->auto_update_frequency = $this->auto_update_frequency; $this->settings->update_check_frequency = $this->update_check_frequency; - $this->settings->save(); $this->server->setupDynamicProxyConfiguration(); if (! $error_show) { @@ -145,7 +145,7 @@ class Configuration extends Component private function validateCronExpression($expression): bool { if (empty($expression)) { - return false; + return true; } $isValid = false; try { @@ -165,14 +165,14 @@ class Configuration extends Component public function updatedAutoUpdateFrequency() { if (!$this->validateCronExpression($this->auto_update_frequency)) { - $this->dispatch('error', 'Invalid Cron / Human expression.'); + $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); } } public function updatedUpdateCheckFrequency() { if (!$this->validateCronExpression($this->update_check_frequency)) { - $this->dispatch('error', 'Invalid Cron / Human expression.'); + $this->dispatch('error', 'Invalid Cron / Human expression for Update Check Frequency.'); } } } \ No newline at end of file diff --git a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php index 25c5666b8..85dafc4b7 100644 --- a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php +++ b/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php @@ -12,8 +12,8 @@ return new class extends Migration public function up(): void { Schema::table('instance_settings', function (Blueprint $table) { - $table->string('update_check_frequency')->default('0 */12 * * *')->nullable(); $table->string('auto_update_frequency')->default('0 0 * * *')->nullable(); + $table->string('update_check_frequency')->default('0 */11 * * *')->nullable(); }); } diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index e9cb7267d..f92e9d79d 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -45,11 +45,9 @@ @else @if($is_auto_update_enabled) - - @error('settings.auto_update_frequency') {{ $message }} @enderror + @endif - - @error('settings.update_check_frequency') {{ $message }} @enderror + @endif From b64d4881cb4f724424b4d774e07e8197e7ad11e4 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:33:20 +0200 Subject: [PATCH 05/19] made helper more clear --- resources/views/livewire/settings/configuration.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index f92e9d79d..08e39adbd 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -45,9 +45,9 @@ @else @if($is_auto_update_enabled) - + @endif - + @endif From 50ede5cab9105a956eed748a4d68d13356031c1f Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 20:57:27 +0200 Subject: [PATCH 06/19] remove comments and remove duplicated scheduling --- app/Console/Kernel.php | 8 ++------ app/Livewire/Settings/Configuration.php | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 92a1b1618..735b75de1 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -45,10 +45,6 @@ class Kernel extends ConsoleKernel $schedule->command('cleanup:unreachable-servers')->daily(); $schedule->job(new PullTemplatesFromCDN)->daily()->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyFiveMinutes()->onOneServer(); - $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency ?? '0 0 * * *')->onOneServer(); - $schedule->job(new CheckForUpdatesJob())->cron($settings->auto_update_frequency ?? '0 11,23 * * *')->onOneServer(); - - // Server Jobs $this->scheduleUpdates($schedule); $this->pull_images($schedule); $this->check_resources($schedule); @@ -76,11 +72,11 @@ class Kernel extends ConsoleKernel { $settings = InstanceSettings::get(); - $updateCheckFrequency = $settings->update_check_frequency ?? '0 0 * * *'; // Default to daily at 00:00 + $updateCheckFrequency = $settings->update_check_frequency ?? '0 0 * * *'; $schedule->job(new CheckForUpdatesJob())->cron($updateCheckFrequency)->onOneServer(); if ($settings->is_auto_update_enabled) { - $autoUpdateFrequency = $settings->auto_update_frequency ?? '0 11,23 * * *'; // Default to twice daily at 11:00 and 23:00 + $autoUpdateFrequency = $settings->auto_update_frequency ?? '0 11,23 * * *'; $schedule->job(new UpdateCoolifyJob())->cron($autoUpdateFrequency)->onOneServer(); } } diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index 2f4c77535..60cd46907 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -91,7 +91,6 @@ class Configuration extends Component } $this->validate(); - // Allow empty values and set defaults if ($this->is_auto_update_enabled && !$this->validateCronExpression($this->auto_update_frequency)) { $this->dispatch('error', 'Invalid Cron / Human expression for Auto Update Frequency.'); return; From d4cb7e25dcb9d3525bb228c8f0d7b7c5bcdef429 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Mon, 5 Aug 2024 21:04:47 +0200 Subject: [PATCH 07/19] renamed database migration file --- ...2659_add_auto_update_frequency_and_update_check_frequency.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename database/migrations/{2024_08_05_142659_add_new_version_available_to_instance_settings_table.php => 2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php} (100%) diff --git a/database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php b/database/migrations/2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php similarity index 100% rename from database/migrations/2024_08_05_142659_add_new_version_available_to_instance_settings_table.php rename to database/migrations/2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php From d9a079c28912b80889eca7e05629ad49f521d46c Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:25:57 +0200 Subject: [PATCH 08/19] fix conflict in kernel.php --- app/Console/Kernel.php | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 735b75de1..314205c60 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -12,6 +12,7 @@ use App\Jobs\PullHelperImageJob; use App\Jobs\PullSentinelImageJob; use App\Jobs\PullTemplatesFromCDN; use App\Jobs\ScheduledTaskJob; +use App\Jobs\ServerCheckJob; use App\Jobs\ServerStatusJob; use App\Jobs\UpdateCoolifyJob; use App\Jobs\CheckForUpdatesJob; @@ -33,23 +34,29 @@ class Kernel extends ConsoleKernel $settings = InstanceSettings::get(); if (isDev()) { + // Instance Jobs + $schedule->command('horizon:snapshot')->everyMinute(); + $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); + $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs $this->check_scheduled_backups($schedule); - $this->check_resources($schedule); - $this->check_scheduled_backups($schedule); + $this->checkResourcesNew($schedule); $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { // Instance Jobs $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('cleanup:unreachable-servers')->daily(); - $schedule->job(new PullTemplatesFromCDN)->daily()->onOneServer(); - $schedule->job(new CleanupInstanceStuffsJob)->everyFiveMinutes()->onOneServer(); $this->scheduleUpdates($schedule); $this->pull_images($schedule); - $this->check_resources($schedule); - $this->check_scheduled_tasks($schedule); + $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); + $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); + $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); + + // Server Jobs $this->check_scheduled_backups($schedule); + $this->checkResourcesNew($schedule); + $this->check_scheduled_tasks($schedule); $schedule->command('cleanup:database --yes')->daily(); $schedule->command('uploads:clear')->everyTwoMinutes(); @@ -81,6 +88,21 @@ class Kernel extends ConsoleKernel } } + private function checkResourcesNew($schedule) + { + 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; + $servers = $servers->merge($own); + } else { + $servers = $this->all_servers->where('ip', '!=', '1.2.3.4'); + } + foreach ($servers as $server) { + $schedule->job(new ServerCheckJob($server))->everyMinute()->onOneServer(); + $schedule->job(new DockerCleanupJob($server))->everyTenMinutes()->onOneServer(); + } + } + private function check_resources($schedule) { if (isCloud()) { From 93322dc3cfd7e688a851ac8b7b5e3567571606c6 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:29:02 +0200 Subject: [PATCH 09/19] updated helper text --- resources/views/livewire/settings/configuration.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index 08e39adbd..e49c9f397 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -47,7 +47,7 @@ @if($is_auto_update_enabled) @endif - + @endif From d9edb1c72f33f3e2ff38e5b409000dc4993dcdfd Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:32:37 +0200 Subject: [PATCH 10/19] fix --- app/Console/Kernel.php | 2 +- resources/views/livewire/settings/configuration.blade.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 314205c60..8e0a7d4b1 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -78,7 +78,7 @@ class Kernel extends ConsoleKernel private function scheduleUpdates($schedule) { $settings = InstanceSettings::get(); - + $updateCheckFrequency = $settings->update_check_frequency ?? '0 0 * * *'; $schedule->job(new CheckForUpdatesJob())->cron($updateCheckFrequency)->onOneServer(); diff --git a/resources/views/livewire/settings/configuration.blade.php b/resources/views/livewire/settings/configuration.blade.php index e49c9f397..8a6a6e572 100644 --- a/resources/views/livewire/settings/configuration.blade.php +++ b/resources/views/livewire/settings/configuration.blade.php @@ -47,7 +47,7 @@ @if($is_auto_update_enabled) @endif - + @endif From f7b1aaca92e7f9eb7c3c8e575ebabd93eac49107 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:35:22 +0200 Subject: [PATCH 11/19] fix fix --- app/Console/Kernel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 8e0a7d4b1..41fa53fb3 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -41,6 +41,8 @@ class Kernel extends ConsoleKernel // Server Jobs $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); + // $this->check_resources($schedule); + $this->check_scheduled_backups($schedule); $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { From c4cf116e6e19d4cd1fe745b2dfa8e6d5babccc86 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:38:30 +0200 Subject: [PATCH 12/19] more fixes --- app/Console/Kernel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 41fa53fb3..7b480830a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,7 +39,6 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs - $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); // $this->check_resources($schedule); $this->check_scheduled_backups($schedule); @@ -50,7 +49,6 @@ class Kernel extends ConsoleKernel $schedule->command('horizon:snapshot')->everyFiveMinutes(); $schedule->command('cleanup:unreachable-servers')->daily(); $this->scheduleUpdates($schedule); - $this->pull_images($schedule); $schedule->job(new PullCoolifyImageJob)->cron($settings->update_check_frequency)->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); $schedule->job(new CleanupInstanceStuffsJob)->everyTwoMinutes()->onOneServer(); @@ -58,6 +56,8 @@ class Kernel extends ConsoleKernel // Server Jobs $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); + // $this->check_resources($schedule); + $this->pull_images($schedule); $this->check_scheduled_tasks($schedule); $schedule->command('cleanup:database --yes')->daily(); From 5f1e1c0ac45c1c1210002a50e3d8bf6f2483af05 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:41:24 +0200 Subject: [PATCH 13/19] fix another conflict --- app/Console/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7b480830a..4da3d032b 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,9 +39,9 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs + $this->check_scheduled_backups($schedule) $this->checkResourcesNew($schedule); // $this->check_resources($schedule); - $this->check_scheduled_backups($schedule); $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { From bb231411388a2fc400db0cc1a68f87faa9100f2d Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:42:01 +0200 Subject: [PATCH 14/19] add backup line twice --- app/Console/Kernel.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 4da3d032b..292a4fc84 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,9 +39,11 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs + $this->check_scheduled_backups($schedule) $this->checkResourcesNew($schedule); // $this->check_resources($schedule); + $this->check_scheduled_backups($schedule) $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { From 2243a3304bd9b6902a23eb3a87adbd87c336fd13 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:43:55 +0200 Subject: [PATCH 15/19] remove duplicates --- app/Console/Kernel.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 292a4fc84..eb27d5c8f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,11 +39,9 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs - - $this->check_scheduled_backups($schedule) + $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); // $this->check_resources($schedule); - $this->check_scheduled_backups($schedule) $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { From fd36e143e05123018cd92c4cebd84e0cb4c63481 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:46:26 +0200 Subject: [PATCH 16/19] final conflict hopfully :) --- app/Console/Kernel.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index eb27d5c8f..f3e124029 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,7 +39,6 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs - $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); // $this->check_resources($schedule); $this->check_scheduled_tasks($schedule); From a426c00a03705e35253fa6f786b530404c8dc1bc Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:47:48 +0200 Subject: [PATCH 17/19] should work :) --- app/Console/Kernel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f3e124029..eb27d5c8f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -39,6 +39,7 @@ class Kernel extends ConsoleKernel $schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer(); $schedule->job(new PullTemplatesFromCDN)->cron($settings->update_check_frequency)->onOneServer(); // Server Jobs + $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); // $this->check_resources($schedule); $this->check_scheduled_tasks($schedule); From 0459baa55e7bce308f841d973be50e306374f0b8 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 11:48:43 +0200 Subject: [PATCH 18/19] Update Kernel.php --- app/Console/Kernel.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index eb27d5c8f..d49ce5f94 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -42,6 +42,7 @@ class Kernel extends ConsoleKernel $this->check_scheduled_backups($schedule); $this->checkResourcesNew($schedule); // $this->check_resources($schedule); + $this->check_scheduled_backups($schedule); $this->check_scheduled_tasks($schedule); $schedule->command('uploads:clear')->everyTwoMinutes(); } else { From 7eacdf23f95f349acfd49ee4c902190b01015634 Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Tue, 6 Aug 2024 12:00:34 +0200 Subject: [PATCH 19/19] fix database migration --- ....php => 2024_08_05_142659_add_update_frequency_settings.php} | 2 ++ 1 file changed, 2 insertions(+) rename database/migrations/{2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php => 2024_08_05_142659_add_update_frequency_settings.php} (86%) diff --git a/database/migrations/2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php b/database/migrations/2024_08_05_142659_add_update_frequency_settings.php similarity index 86% rename from database/migrations/2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php rename to database/migrations/2024_08_05_142659_add_update_frequency_settings.php index 85dafc4b7..b24842dcd 100644 --- a/database/migrations/2024_08_05_142659_add_auto_update_frequency_and_update_check_frequency.php +++ b/database/migrations/2024_08_05_142659_add_update_frequency_settings.php @@ -14,6 +14,7 @@ return new class extends Migration Schema::table('instance_settings', function (Blueprint $table) { $table->string('auto_update_frequency')->default('0 0 * * *')->nullable(); $table->string('update_check_frequency')->default('0 */11 * * *')->nullable(); + $table->boolean('new_version_available')->default(false); }); } @@ -25,6 +26,7 @@ return new class extends Migration Schema::table('instance_settings', function (Blueprint $table) { $table->dropColumn('update_check_frequency'); $table->dropColumn('auto_update_frequency'); + $table->dropColumn('new_version_available'); }); } };