Supervisor
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:consume
in 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:
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 -
/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
. [program:queue-uvodo]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/example.com/bin/console queue:consume
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/queue-uvodo-worker.log
stopwaitsecs=3600
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/example.com/bin/console
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:
autostart=true
autorestart=true
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 theerrno
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:
stdout_logfile=/var/log/queue-uvodo-worker.log
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.
Last modified 5mo ago