diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 64b415d243fd..24a661eae68f 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -15,6 +15,7 @@ use App\Jobs\Cron\RecurringInvoicesCron; use App\Jobs\Ninja\AdjustEmailQuota; use App\Jobs\Ninja\CompanySizeCheck; use App\Jobs\Util\ReminderJob; +use App\Jobs\Util\SchedulerCheck; use App\Jobs\Util\SendFailedEmails; use App\Jobs\Util\UpdateExchangeRates; use App\Jobs\Util\VersionCheck; @@ -42,7 +43,6 @@ class Kernel extends ConsoleKernel protected function schedule(Schedule $schedule) { - //$schedule->job(new RecurringInvoicesCron)->hourly(); $schedule->job(new VersionCheck)->daily()->withoutOverlapping(); $schedule->command('ninja:check-data')->daily()->withoutOverlapping(); @@ -57,13 +57,20 @@ class Kernel extends ConsoleKernel /* Run hosted specific jobs */ if (Ninja::isHosted()) { + $schedule->job(new AdjustEmailQuota())->daily()->withoutOverlapping(); $schedule->job(new SendFailedEmails())->daily()->withoutOverlapping(); + } - /* Run queue's in shared hosting with this*/ + /* Run queue's with this*/ if (Ninja::isSelfHost()) { + $schedule->command('queue:work')->everyMinute()->withoutOverlapping(); - $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); //we need to add this as we are seeing cached queues mess up the system on first load. + + //we need to add this as we are seeing cached queues mess up the system on first load. + $schedule->command('queue:restart')->everyFiveMinutes()->withoutOverlapping(); + $schedule->job(new SchedulerCheck)->everyFiveMinutes()->withoutOverlapping(); + } } diff --git a/app/Jobs/Util/SchedulerCheck.php b/app/Jobs/Util/SchedulerCheck.php new file mode 100644 index 000000000000..260d948f69e1 --- /dev/null +++ b/app/Jobs/Util/SchedulerCheck.php @@ -0,0 +1,38 @@ +update(['is_scheduler_running' => true]); + } +} diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index 6475834ddc85..49878080f8c2 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -76,6 +76,7 @@ class AccountTransformer extends EntityTransformer 'report_errors' => (bool) $account->report_errors, 'debug_enabled' => (bool) config('ninja.debug_enabled'), 'is_docker' => (bool) config('ninja.is_docker'), + 'is_scheduler_running' => (bool) $account->is_scheduler_running, ]; } diff --git a/database/migrations/2021_01_23_044502_scheduler_is_running_check.php b/database/migrations/2021_01_23_044502_scheduler_is_running_check.php new file mode 100644 index 000000000000..5c8d2e91a928 --- /dev/null +++ b/database/migrations/2021_01_23_044502_scheduler_is_running_check.php @@ -0,0 +1,30 @@ +boolean('is_scheduler_running')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}