This commit is contained in:
Andras Bacsai 2024-08-07 09:50:29 +02:00
parent 869f0878c2
commit e4c3d61b76
4 changed files with 18 additions and 16 deletions

View File

@ -19,6 +19,7 @@ public function handle()
echo "Running database cleanup in dry-run mode...\n";
}
if (isCloud()) {
// Later on we can increase this to 180 days or dynamically set
$keep_days = 60;
} else {
$keep_days = 60;

View File

@ -34,24 +34,24 @@ protected function schedule(Schedule $schedule): void
// 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->checkResourcesNew($schedule);
$this->check_resources($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();
$this->scheduleUpdates($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();
$this->schedule_updates($schedule);
// Server Jobs
$this->check_scheduled_backups($schedule);
$this->checkResourcesNew($schedule);
$this->check_resources($schedule);
$this->pull_images($schedule);
$this->check_scheduled_tasks($schedule);
@ -72,7 +72,7 @@ private function pull_images($schedule)
}
}
private function scheduleUpdates($schedule)
private function schedule_updates($schedule)
{
$settings = InstanceSettings::get();
@ -85,7 +85,7 @@ private function scheduleUpdates($schedule)
}
}
private function checkResourcesNew($schedule)
private function check_resources($schedule)
{
if (isCloud()) {
$servers = $this->all_servers->whereNotNull('team.subscription')->where('team.subscription.stripe_trial_already_ended', false)->where('ip', '!=', '1.2.3.4');

View File

@ -22,15 +22,16 @@ public function __construct() {}
public function handle(): void
{
try {
if (! isDev()) {
ray('PullTemplatesAndVersions service-templates');
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
if ($response->successful()) {
$services = $response->json();
File::put(base_path('templates/service-templates.json'), json_encode($services));
} else {
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
}
if (isDev() || isCloud()) {
return;
}
ray('PullTemplatesAndVersions service-templates');
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
if ($response->successful()) {
$services = $response->json();
File::put(base_path('templates/service-templates.json'), json_encode($services));
} else {
send_internal_notification('PullTemplatesAndVersions failed with: '.$response->status().' '.$response->body());
}
} catch (\Throwable $e) {
send_internal_notification('PullTemplatesAndVersions failed with: '.$e->getMessage());

View File

@ -505,7 +505,7 @@ function get_service_templates(bool $force = false): Collection
{
if ($force) {
try {
$response = Http::retry(3, 50)->get(config('constants.services.official'));
$response = Http::retry(3, 1000)->get(config('constants.services.official'));
if ($response->failed()) {
return collect([]);
}