Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stratboy's avatar

How to configure and use supervisor to keep up and running Scout's queues?

So I already did this, withiin a sail/Docker installation: installed supervisor, published its configs in /docker anddid setup, all up and running, I can see the processes in http://localhost:9001.

I'm also using Scout w/ mailisearch, and it's up and running. And I configured scout to use queues, with redis. Fine.

But now I want to configure supervisor to keep alive the scout's queue work. I know I can avoid in local development, but I want to simulate the exact things I'll do in production, and have an almost ready config when I'll deploy the app.

So how to configure supervisor to keep alive Scout's queues?

0 likes
4 replies
LaryAI's avatar
Level 58

To configure Supervisor to keep Scout's queues running, you need to create a Supervisor configuration file that will manage the Laravel queue worker. Here’s a step-by-step guide to achieve this:

  1. Install Supervisor: Since you mentioned you have already installed Supervisor, we can skip this step. For others, you can install Supervisor using the following command:

    sudo apt-get install supervisor
    
  2. Create Supervisor Configuration File: Create a new configuration file for your Laravel queue worker. This file is typically placed in /etc/supervisor/conf.d/. For Docker, you might place it in your Docker configuration directory.

    Create a file named laravel-worker.conf:

    sudo nano /etc/supervisor/conf.d/laravel-worker.conf
    
  3. Add Configuration for Laravel Queue Worker: Add the following configuration to the laravel-worker.conf file. This configuration will tell Supervisor to manage the Laravel queue worker process.

    [program:laravel-worker]
    process_name=%(program_name)s_%(process_num)02d
    command=php /path/to/your/project/artisan queue:work redis --sleep=3 --tries=3 --timeout=90
    autostart=true
    autorestart=true
    user=your-username
    numprocs=1
    redirect_stderr=true
    stdout_logfile=/path/to/your/project/storage/logs/worker.log
    

    Replace /path/to/your/project with the actual path to your Laravel project and your-username with the user that should run the worker.

  4. Update Supervisor Configuration: After creating the configuration file, you need to update Supervisor to read the new configuration.

    sudo supervisorctl reread
    sudo supervisorctl update
    
  5. Start the Laravel Worker: Start the Laravel worker process using Supervisor.

    sudo supervisorctl start laravel-worker:*
    
  6. Verify the Worker is Running: You can verify that the worker is running by checking the Supervisor status.

    sudo supervisorctl status
    

    You should see an entry for laravel-worker with a status of RUNNING.

Docker Considerations

If you are using Docker, you need to ensure that Supervisor is installed and configured within your Docker container. You can add Supervisor to your Dockerfile and copy the configuration file into the container.

Here’s an example Dockerfile snippet:

# Install Supervisor
RUN apt-get update && apt-get install -y supervisor

# Copy Supervisor configuration
COPY ./docker/laravel-worker.conf /etc/supervisor/conf.d/laravel-worker.conf

# Add Supervisor to the entrypoint
CMD ["/usr/bin/supervisord"]

Make sure to adjust the paths and commands according to your Docker setup.

By following these steps, you should be able to configure Supervisor to keep your Scout's queues running, both in local development and in production.

gych's avatar

Which OS are you using?

gych's avatar

@stratboy Ok you want to run it locally on your Mac instead of using a Docker container right? Did you already install supervisor?

Please or to participate in this conversation.