How can I monitor if the Laravel queue is running? How can I monitor if the Laravel queue is running? laravel laravel

How can I monitor if the Laravel queue is running?


This is lower level but in the same vein you could run a command such as ps -aux | grep queue to literally view the running queue processes on whatever server your application/queue workers are running on.


Actually, when a queue fails a failing event fires, so for example, you may register the failing event in your AppServiceProvider class in the boot method using something like this:

public function boot(){    Queue::failing(function (JobFailed $event) {        // $event->connectionName        // $event->job        // $event->data    });}

Alternatively, you can declare a failed method in the handler class for example:

class SendEmail extends Job implements ShouldQueue{    use InteractsWithQueue, SerializesModels;    public function handle(Mailer $mailer)    {        //...    }    public function failed()    {        //...    }}

The Updated link.

Regarding background monitoring, you may use Supervisord:

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.

In this case, you have to install it on your machine and configure it using at least one program section, for example:

[program:queue]command=/usr/local/bin/php artisan queue:listen --tries=3

This is an example of program section that I've used to monitor my queue using Supervisord. In this case, you need to read the documentation for the supervisord to understand how to use it, I've just gave you an idea. The supervisord will run in the background once you start it and it'll also restart the observation even after the server is restarted (if it goes down for some reason) so you don't need to worry about that.

A simple (minimal) config file may look something like this:

[unix_http_server]file=/tmp/supervisor.sock   ; (the path to the socket file)[supervisord]logfile=/home/someDirName/www/example.com/supervisord.loglogfile_maxbytes=50MBlogfile_backups=10loglevel=infopidfile=/tmp/supervisord.pidnodaemon=falseloglevel=warn[rpcinterface:supervisor]supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]serverurl=unix:///tmp/supervisor.sock[program:queue]command=/usr/local/bin/php artisan queue:listen --tries=3directory=/home/someDirName/www/example.comautostart=trueautorestart=trueredirect_stderr=true

Well, you may read the documentation to really get the clear idea about it. This may help you to start.


There is no method like you say

\Queue::isListening();

But you can configure Supervisor: A process control system to look after your queue. here is a the Laravel documentation for supervisor configuation https://laravel.com/docs/5.1/queues#supervisor-configuration