fix get corn job correctly form server settings

This commit is contained in:
ayntk-ai 2024-08-14 21:52:12 +02:00
parent 365f957b8a
commit 53bcf81af5
No known key found for this signature in database

View File

@ -29,12 +29,13 @@ protected function schedule(Schedule $schedule): void
{
$this->all_servers = Server::all();
$settings = InstanceSettings::get();
$mainServer = Server::find(0);
$serverSettings = $mainServer->settings;
if (isDev()) {
// Instance Jobs
$schedule->command('horizon:snapshot')->everyMinute();
$schedule->job(new CleanupInstanceStuffsJob)->everyMinute()->onOneServer();
// Server Jobs
$this->check_scheduled_backups($schedule);
$this->check_resources($schedule);
@ -43,10 +44,10 @@ protected function schedule(Schedule $schedule): void
} else {
// Instance Jobs
$schedule->command('horizon:snapshot')->everyFiveMinutes();
$schedule->command('cleanup:unreachable-servers')->cron($settings->server_cleanup_frequency)->onOneServer();
$schedule->command('cleanup:unreachable-servers')->cron($serverSettings->server_cleanup_frequency)->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($settings->server_cleanup_frequency)->onOneServer();
$schedule->job(new CleanupInstanceStuffsJob)->cron($serverSettings->server_cleanup_frequency)->onOneServer();
$this->schedule_updates($schedule);
// Server Jobs
@ -56,7 +57,7 @@ protected function schedule(Schedule $schedule): void
$this->check_scheduled_tasks($schedule);
$schedule->command('cleanup:database --yes')->daily();
$schedule->command('uploads:clear')->cron($settings->server_cleanup_frequency)->onOneServer();
$schedule->command('uploads:clear')->cron($serverSettings->server_cleanup_frequency)->onOneServer();
}
}
@ -94,7 +95,9 @@ private function schedule_updates($schedule)
private function check_resources($schedule)
{
$settings = InstanceSettings::get();
$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;
@ -104,7 +107,7 @@ private function check_resources($schedule)
}
foreach ($servers as $server) {
$schedule->job(new ServerCheckJob($server))->everyMinute()->onOneServer();
$schedule->job(new DockerCleanupJob($server))->cron($settings->server_cleanup_frequency)->onOneServer();
$schedule->job(new DockerCleanupJob($server))->cron($serverSettings->server_cleanup_frequency)->onOneServer();
}
}