From c94358350a806484a9446bedfe75bfb8bbfbd4bc Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Fri, 21 May 2021 12:31:32 -0400 Subject: [PATCH] Add queue worker setting so those aren't run in cron if there's a worker --- app/Console/Kernel.php | 9 ++++++--- config/queue.php | 5 +++++ resources/stubs/installer/env.stub | 27 ++++++++++++++++++++------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 726109a0..27c8ba11 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -26,9 +26,12 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule): void { - $schedule->command(JobQueue::class) - ->everyMinute() - ->withoutOverlapping(); + // If not using the queue worker then run those via cron + if (!config('queue.worker', false)) { + $schedule->command(JobQueue::class) + ->everyMinute() + ->withoutOverlapping(); + } $schedule->command(Nightly::class)->dailyAt('01:00'); $schedule->command(Weekly::class)->weeklyOn(0); diff --git a/config/queue.php b/config/queue.php index e4026e0d..036bc3d2 100755 --- a/config/queue.php +++ b/config/queue.php @@ -16,6 +16,11 @@ return [ 'default' => env('QUEUE_DRIVER', 'sync'), + /** + * If you're using the queue worker, then disable running queued tasks via cron + */ + 'worker' => env('QUEUE_WORKER', false), + /* |-------------------------------------------------------------------------- | Queue Connections diff --git a/resources/stubs/installer/env.stub b/resources/stubs/installer/env.stub index 27e42dd9..f9480caa 100644 --- a/resources/stubs/installer/env.stub +++ b/resources/stubs/installer/env.stub @@ -22,7 +22,8 @@ LOG_LEVEL=debug APP_DEBUG=$APP_DEBUG$ DEBUG_TOOLBAR=$DEBUG_TOOLBAR$ -# DATABASE SETTINGS +## DATABASE SETTINGS + DB_CONNECTION=$DB_CONNECTION$ DB_HOST='$DB_HOST$' DB_PORT=$DB_PORT$ @@ -33,18 +34,19 @@ DB_PREFIX='$DB_PREFIX$' DB_EMULATE_PREPARES=$DB_EMULATE_PREPARES$ DB_SOCKET= -# CACHE SETTINGS +## CACHE SETTINGS +# https://docs.phpvms.net/config/optimizing#caching + CACHE_DRIVER=$CACHE_DRIVER$ CACHE_PREFIX='$CACHE_PREFIX$' -# QUEUE SETTINGS -# Set this to "database" if you have slow pages due to notifications/emails -# They will then be sent out via cron -QUEUE_DRIVER=sync +## EMAIL SETTINGS -# EMAIL SETTINGS # Look at the available mail configs in config/mail.php # Also refer to the Laravel docs here: https://laravel.com/docs/8.x/mail +# If you're using SMTP, I recommend setting the QUEUE_DRIVER to 'database' +# https://docs.phpvms.net/config/optimizing#queue-driver + MAIL_DRIVER=$MAIL_DRIVER$ MAIL_FROM_NAME='$MAIL_FROM_NAME$' MAIL_FROM_ADDRESS='$MAIL_FROM_ADDRESS$' @@ -53,3 +55,14 @@ MAIL_PORT=$MAIL_PORT$ MAIL_ENCRYPTION=$MAIL_ENCRYPTION$ MAIL_USERNAME=$MAIL_USERNAME$ MAIL_PASSWORD=$MAIL_PASSWORD$ + +## QUEUE SETTINGS + +# Set this to "database" if you have slow pages due to notifications/emails +# They will then be sent out via cron +QUEUE_DRIVER=sync + +# If you're using the Laravel Queue Worker, set this to true. This will stop the queue tasks +# from being run during the cron job +# https://laravel.com/docs/8.x/queues#running-the-queue-worker +QUEUE_WORKER=false