Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I learn more about why my Laravel Queued Job failed?

Tags:

php

queue

laravel

The Situation

I'm using Laravel Queues to process large numbers of media files, an individual job is expected to take minutes (lets just say up to an hour).

I am using Supervisor to run my queue, and I am running 20 processes at a time. My supervisor config file looks like this:

[program:duplitron-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/duplitron/artisan queue:listen database --timeout=0 --memory=500 --tries=1
autostart=true
autorestart=true
user=duplitron
numprocs=20
redirect_stderr=true
stdout_logfile=/var/www/duplitron/storage/logs/duplitron-worker.log

In my duplitron-worker.log I noticed Failed: Illuminate\Queue\CallQueuedHandler@call occurs occasionally and I would like to better understand what exactly is failing. Nothing appears in my laravel.log file (which is where exceptions would normally appear).

The Question

Is there a handy way for me to learn more about what is causing my job to fail?

like image 291
slifty Avatar asked Dec 27 '15 21:12

slifty


People also ask

How do I know if my Laravel queue is working?

Show activity on this post. 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.

How do I rerun failed jobs in Laravel?

You can retry all failed Jobs by running: php artisan queue:retry all . The question is for Laravel 4, but yes. From Laravel 5 and forward this is the correct answer.

What is queue job in Laravel?

Laravel queues provide a unified queueing API across a variety of different queue backends, such as Amazon SQS, Redis, or even a relational database. Laravel's queue configuration options are stored in your application's config/queue.php configuration file.


1 Answers

In the newer Laravel versions there's an exception column in the failed_jobs table that has all the info you need. Thanks cdarken and Toskan for pointing this out!

==== OLD METHOD BELOW

Here's what I always do, but first - make sure you have a failed-jobs table! It's well documented, look it up :)

  1. Run the php artisan queue:failed command to list all the failed jobs, and pick the one you're after. Write the ID down.

  2. Then, make sure to stop your queue with supervisorctl stop all duplitron-worker:

  3. Lastly, make sure your .env setting for APP_DEBUG = true.

  4. Then run php artisan queue:retry {step_job_1_id}

  5. Now manually runphp artisan queue:listen --timeout=XXX

If the error is structural (and most are), you should get the failure with debug stack in your log file.

Good luck with debugging :-)

like image 152
Stan Smulders Avatar answered Sep 29 '22 12:09

Stan Smulders