Message Queue Setup with ddev
This page explains how to setup the messenger:consume and scheduled-task:run workers (the "message queue") in a ddev environment, mirroring a production server setup.
At some point it might be desired to mirror your local development or your demo environment as closely as possible to the production environment. When it comes to Symfony's or Shopware's message queue, this can be achieved easily with ddev.
Supervisor
ddev has supervisord implemented as a control system for running automated tasks. ddev actually uses supervisord itself to schedule internal tasks. So essentially all we need to do is to extend the supervisord worker configuration.
Defining supervisord Workers
To do so, add file worker.conf
to the folder .ddev/web-build
:
For an explanation of the message queue worker configuration in general, head over to the Symfony docs.
Should you need or want more than one instance of a particular worker, just adjust the numproc
directive.
Create a Persistent Worker Command
Note that the command
directive in the above file does not call the bin/console commands directly. Instead, a self-written shell script run-worker.sh
is executed. The reason for this is
supervisord with ddev cannot handle processes that kill themselves, such as the messenger:consume
and scheduled-task:run
commands when you use the --time-limit
or --message-limit
parameters. We need persistent commands for our supervisors. The solution is a custom script in your project's bin folder shopware/bin
:
This script just uses an endless loop to feed whatever command you provide as an argument to bin/console.
Activate the Worker Configuration
Finally, to activate your worker configuration with ddev, add a file Dockerfile.worker
to the folder .ddev/web-build
and restart ddev.
Verify Workers are Active
To verify your workers have been started and are active, simply run the command
You should see your workers being listed (amongst the other running processes):
Don't Forget to Deactivate the Admin Worker
Add a file z-shopware.yaml
to your shopware/config/packages
folder:
Last updated