ITZone

Configure Supervisor to run Laravel Queue on Linux

Perhaps everyone is not familiar with Laravel Queue, so I will not re-introduce it. Everyone can go to the Laravel doc to read it!

As everyone knows for Queue to work, we have to run the command:

Queue runs continuously without stopping, so if we use the terminal (or cmd), when we turn off the terminal / cmd, it will be considered that the queue will also turn off (annoying, isn’t it everyone). And today I will introduce all supervisor users to help us do this. Let’s find out together!

1. What is a Supervisor?

Supervisor is a tool to help manage processes running on Linux. Some advantages that Supervisor like:

2. Install Supervisor

To install Supervisor, people run the following command on Linux:

After the installation is complete, supervisor can create a /etc directory on the machine.

3. Basic Configuration Supervisor

Each process supervised by Supervisor will be configured in a file of the form .conf located in the directory /etc/supervisor/conf.d

The structure of a basic config file is as follows:

After the configuration is complete, run the following command to restart supervisor

Note: Every time you change the Supervisor configuration information, everyone needs to restart Supervisor.

4. Implement Supervisor to run Laravel Queue

5. Some commonly used commands

Command Detail
sudo service supervisor restart Restart all supervisors
sudo supervisorctl start laravel-worker:* Start worker laravel-worker:*
sudo supervisorctl stop laravel-worker:* Stop worker laravel-worker:*
sudo supervisorctl restart laravel-worker:* Restart worker laravel-worker:*

Conclude

So with supervisor, it will be easier to manage and run Laravel Queue, we also have less to worry about how its process is running, unless there is an error, we have to check the log.

Hope this article is helpful to everyone.

Thanks for reading

References http://supervisord.org/index.html

https://phambinh.net/bai-viet/cau-hinh-laravel-queue-tren-moi-truong-production/

Share the news now