Shopware CLI

Shopware CLI is installed automatically when any PHP app has subtype: shopware6.

Host vars:

apps:
  - name: shop
    type: php
    subtype: shopware6

Defaults:

  • No config; installation is triggered by app subtype.

Shopware-specific configuration

Systemd Message Consumers

Shopware uses the Symfony Messenger component and Enqueue to handle asynchronous messages. This allows tasks to be processed in the background. Thus, tasks can be processed independently of timeouts or system crashes. By default, tasks in Shopware are stored in the database and processed via the browser as long as you are logged into the Administration. This is a simple and fast method for the development process, but not recommended for production systems. With multiple users logged into the Administration, this can lead to a high CPU load and interfere with the smooth execution of PHP FPM.

On a production system, the message queue should be processed via the CLI instead of the browser in the Administration (Admin worker). It is recommended to run one or more messenger:consume workers. To automatically start the processes again after they stopped because of exceeding the given limits you can use a process control system like systemd.

Probably you are familiar with the system-wide systemd services, managed by the systemctl command. But systemd services can also be entirely controlled by regular unprivileged users. So it means to configure this you don't root access but you run can the serices under a regular user account.

Create the following files:

# ~/.config/systemd/user/shopware-message-consume@.service

[Unit]
Description=Shopware Message Queue Consumer (#%i)
After=network-online.target
Requires=dbus.socket
StartLimitIntervalSec=0
PartOf=shopware.target

[Service]
Type=simple
WorkingDirectory=%h/current
ExecStart=php %h/current/bin/console messenger:consume --time-limit=600 --memory-limit=256M async low_priority
RestartSec=10s
Restart=always

[Install]
WantedBy=default.target
# ~/.config/systemd/user/shopware-scheduled-task.service

[Unit]
Description=Shopware scheduled tasks
After=network-online.target
StartLimitIntervalSec=0
Requires=dbus.socket
PartOf=shopware.target

[Service]
Type=simple
Restart=always
RestartSec=10s
WorkingDirectory=%h/current
ExecStart=/usr/bin/php %h/current/bin/console scheduled-task:run --memory-limit=128M --time-limit=300

[Install]
WantedBy=default.target

To spin up 2 message consumers & 1 scheduled task manager:

# ~/.config/systemd/user/shopware.target

[Unit]
Description=Shopware Workers
Wants=shopware-message-consume@1.service shopware-message-consume@2.service shopware-scheduled-task.service

[Install]
WantedBy=default.target

Run these commandsto enable and start the service. It will be auto started again after reboot.

systemctl daemon-reload --user
systemctl start shopware.target --user
systemctl enable shopware.target --user