How to Deactivate the Admin Worker and Set Up CLI Worker in Shopware?

The Most Popular Extension Builder for Magento 2

With a big catalog of 224+ extensions for your online store

When a significant number of users enter into Shopware’s administration, the CPU load can get overwhelmed, disrupting the message queues’ smooth execution. In such situations, you ought to turn off the admin worker and allow the processes to operate through the CLI.

So, how can you do that in Shopware? In today’s article, we will show you how to deactivate the admin worker and set up CLI worker in Shopware. Let’s get started!

Table of contents

What is the Admin Worker in Shopware?

By default, Shopware performs all actions asynchronously. This has the advantage of allowing vital processes to run independently of unwanted timeouts or system failures. All asynchronous jobs are stored in the message queue.

In Shopware 6, the administration’s message queues are automatically processed in the background by the so-called Admin Worker. This allows for very rapid admin tasks.

Why Do You Need to Deactivate the Admin Worker and Set Up CLI Worker in Shopware?

As we have just discussed admin worker, it is worth noting that this approach needs the Administration to remain open for a longer amount of time. Therefore, in case a huge number of users are logged into the administration, the CPU load could get too high to handle. This would result in the impairment of the message queues’ smooth operation.

In such instances, it is best to turn off the admin worker and allow the processes to run through the CLI. Thus, tasks can be done even when no one is signed into the administration, and a significant CPU burden generated by multiple users can also be prevented. Besides, this method is especially effective for big stores.

How to Deactivate the Admin Worker and Set Up CLI Worker in Shopware?

Now we will give you detailed instructions on how to deactivate the admin worker and set up CLI worker in Shopware in just 2 steps. But first, please keep in mind that the Shopware standard does not allow for the deactivation of the admin worker, thus manual modifications must be done at the server level. It’s advisable to contact your hoster if you’re unsure.

Step 1: Customize files

To disable the admin worker, you need to make the necessary changes to the shopware.yaml file. It’s at config/packages/ in your Shopware installation. After that, you need to use “false” to disable the admin worker. Then, remember to save the file.

# config/packages/shopware.yaml
shopware:
    admin_worker:
        enable_admin_worker: false

Step 2: Execute CLI commands

Now, you need to use the CLI and run the following commands one after the other.

bin/console messenger:consume default --time-limit=60
bin/console scheduled-task:run --time-limit=60

For the aforementioned commands, we recommend using time-limit=60 to ensure that the command is run for a maximum of 60 seconds. You can also set a memory limit instead of a time limit.

bin/console messenger:consume default --time-limit=60 --memory-limit=128M

Lastly, it is critical that the commands be run on a regular basis in order for the message queue to be processed consistently. This can be accomplished, for example, by setting up a cron job on the server. You should get in touch with your hoster for more information about this.

Final Words

By default, when you are logged into the administration, tasks in Shopware are kept in the database and processed through the browser. This is a quick and easy way for development, but it is not advised for production systems. On a productive system, the message queue should be handled through the CLI rather than the browser in the administration (Admin worker).

We hope that our comprehensive instructions on how to deactivate the admin worker and set up CLI worker in Shopware have helped you to successfully manage your Shopware store and build a smooth and prosperous online business.

Increase sales,
not your workload

Simple, powerful tools to grow your business. Easy to use, quick to master and all at an affordable price.

Get Started
avada marketing automation

Explore Our Products:

Subscribe

Stay in the know

Get special offers on the latest news from Mageplaza.

Earn $10 in reward now!

Earn $10 in reward now!

comment
iphone
go up