Learn how to install supervisor for handling queue

What is Supervisor?

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.

Why do we need supervisor?

Supervisor is needed to run and listen the command - php bin/console queue:consume in the background.

How to install Supervisor at Ubuntu?

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. 1.
    You have to go to Uvodo project folder - /uvodo_project/etc/supervisor/conf.d.
2. There is a file named queue-worker.conf. You can copy the whole content of the file and go to /etc/supervisor/conf.d.
command=php /var/www/ queue:consume
3. Create new conf file with the name uvodo-queue-worker.conf and paste the above copied content.
4. Change the command parameter's value - /var/www/ with your project structure. This bin/console location which is located under your Uvodo project's root folder.
Below two lines define the automatic behavior of the script under certain conditions:
The autostart option 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.
autorestart defines how Supervisor should manage the program in the event that it exits:
  • false tells Supervisor not to ever restart the program after it exits.
  • true tells Supervisor to always restart the program after it exits.
  • unexpected tells 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 errno command.
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.