Learn how to install supervisor for handling queue
Supervisor is a process manager which provides a singular interface for managing and monitoring a number of long-running programs. In this tutorial, you will install Supervisor on a Linux server and learn how to manage Supervisor configurations for multiple applications.
Supervisor is needed to run and listen the command -
php bin/console queue:consumein the background.
Ubuntu 20.04 version is required to run the following commands.
Begin by updating your package sources and installing Supervisor.
sudo apt update && sudo apt install supervisor
The Supervisor service runs automatically after installation. You can check its status:
sudo systemctl status supervisor
Output● supervisor.service - Supervisor process control system for UNIX
Loaded: loaded (/lib/systemd/system/supervisor.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-10-07 13:24:48 UTC;
After successful installation,
- 1.You have to go to Uvodo project folder -
2. There is a file named
queue-worker.conf. You can copy the whole content of the file and go to
command=php /var/www/example.com/bin/console queue:consume
3. Create new
conffile with the name
uvodo-queue-worker.confand paste the above copied content.
4. Change the
commandparameter's value -
/var/www/example.com/bin/consolewith your project structure. This
bin/consolelocation which is located under your Uvodo project's root folder.
Below two lines define the automatic behavior of the script under certain conditions:
autostartoption tells Supervisor that this program should be started when the system boots. Setting this to false will require a manual start following any system shutdown.
autorestartdefines how Supervisor should manage the program in the event that it exits:
falsetells Supervisor not to ever restart the program after it exits.
truetells Supervisor to always restart the program after it exits.
unexpectedtells Supervisor to only restart the program if it exits with an unexpected error code (by default anything other than codes 0 or 2). To learn more about error codes, look into the
After creating and saving the supervisor conf file, you need to restart Supervisor:
sudo systemctl restart supervisor
You can debug and check outputs from the below location:
That's it. Now, your project listen your active message broker.
Currently, mailer plugin works with Queue and we have only Database Queue plugin.
If you want to install supervisor, then you need to install database queue plugin. Our default service for queue is file based queue service. If there is not any queue plugin, file based plugin comes with our core modules. No need to install database plugin.