🕺
LaravelSharedHosting
  • Some hints and best practices for deploying laravel on shared hosts
  • SiteGround Shared Hosting
    • Introduction
    • Prepare your Laravel project
    • Add a hosting account
    • SSH access to SiteGround space
    • Setup a mysql database
    • Adding a mail account
    • The master folder
    • Create a .env file
    • Connect your server to git
    • Create a deployment script
    • Link this site into your webserver
    • SSL Certificate
    • Setting up a CRON job
    • Running a Queue Worker
    • On-going deployments
    • Deploy from local development
    • Deploy using GitHub Actions
Powered by GitBook
On this page
  1. SiteGround Shared Hosting

Running a Queue Worker

Its common that with shared hosting, it is not possible to run supervisor to manage queue workers.

One approach for non-time sensitive queue work (such as sending emails) is to add a task to the scheduler that starts the queue worker every minute;

Console/Kernel.php
$schedule->command('queue:work --stop-when-empty')
             ->everyMinute()
             ->withoutOverlapping();

Adding this line to the scheduler in app\Console\Kernel.php and then setting up a cron job to run the scheduler, ensures that the queue gets serviced every minute.

The queue worker will run until there are no more jobs to process and then terminate. If there is more than one minutes worth of work, then the worker will keep running and the withoutOverlapping() function ensures that a second worker is not started if one is already running.

PreviousSetting up a CRON jobNextOn-going deployments

Last updated 2 years ago