Queues
Some processes in your application take a long time to complete. For example, sending emails, processing videos, etc.
ColibriPlus runs these processes in the background so users don't have to wait for them to complete. Laravel Queues are used to handle these processes.
What is a queue?
Queues are a way to handle these processes in the background. When your user initiates a long process, like uploading video or audio, or sending email, ColibriPlus puts it into a special database table and then processes them one by one in the background.
Learn more about Laravel Queues here.
Configuration
ColibriPlus uses Laravel Queues with the Horizon package to handle these processes. Horizon is a tool for monitoring and managing Laravel queues.
It's already installed when you install ColibriPlus dependencies by running the composer install
command.
Redis is required 🔴
Please make sure you have installed and configured Redis on your server, because Horizon uses Redis to store the data.
Read more about Redis installation In Installation Guide.
Queue storage
The next step is to tell ColibriPlus to use Redis for queues. Open the .env
file and set QUEUE_CONNECTION
to redis
.
QUEUE_CONNECTION=redis
Start Horizon
Once everything above is done, you can start the Horizon server by running this command:
php colibri horizon
Supervisor
For production environments, use Supervisor to manage the Horizon server. Supervisor is a process manager for Unix-like operating systems that can automatically restart the Horizon server if it crashes.
Create a Supervisor configuration file:
sudo nano /etc/supervisor/conf.d/horizon.conf
Add the following configuration:
[program:horizon]
# Replace with your actual path
directory=/path/to/your/colibriplus/
command=php colibri horizon
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/colibriplus/storage/logs/horizon.log
stopwaitsecs=3600
WARNING
Set numprocs=1
for Horizon as it doesn't support multiple processes out of the box. For scaling, consider using a load balancer.
Apply the Supervisor configuration:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start horizon:*
Check the status:
sudo supervisorctl status horizon:*