# Queue Configuration

Enable the queue to process certain tasks (such as: email, one-click generation of language packs in the language pack translation plug-in (opens new window)), the configuration steps are as follows:

1.Configuring a database driver to handle queues

(1)In the .env file, set the queue driver to database

QUEUE_CONNECTION=database

(2)Execute the command to create the table(failed_jobs、jobs)

php artisan queue:table

php artisan migrate

These two commands will create the jobs table for storing queue tasks and the failed_jobs table for storing failed tasks respectively.

(4)Execute the command to enable the queue

php artisan queue:work -v

2.Dealing with Common Problems

(1)View related tables failed_jobs, jobs, and notifications (You can use database management tools to view the data in these tables.)

(2)View the console output information (When executing the php artisan queue:work -v command, the console will output the execution process of the task. If there is a problem, it will display error information to help you diagnose the problem during the task processing.)

3.In a production environment, you need a way to keep queue:work processes running. queue:work processes can stop running for a variety of reasons, such as exceeding a worker timeout or executing a queue:restart command. For this reason, you need to configure a queue service that can detect when your queue:work processes exit and automatically restart them.

(1) Open the BTpanel terminal and enter the /lib/systemd/system directory

cd /lib/systemd/system

(2) Create beikeshop.service

vim beikeshop.service

(3)In the created beikeshop.service file, fill in the following content:

[Unit]
Description=Beikeshop

[Service]
Type=simple
Restart=on-failure
User=root
ExecStart=/usr/bin/php <Site Directory>/artisan queue:work --queue=default,gen_language_pack

[Install]
WantedBy=multi-user.target

Save and exit

(4)After the service is created, you can manage the beikeshop.service service with the following command

sudo systemctl start beikeshop.service //Start up
sudo systemctl stop beikeshop.service //Stop
sudo systemctl restart beikeshop.service //Restart
sudo systemctl status beikeshop.service //View Status
sudo systemctl enable beikeshop.service //Startup