我怎样才能了解更多关于我的 Laravel 排队作业失败的原因?
情况
我正在使用 Laravel 队列来处理大量媒体文件,单个作业预计需要几分钟(假设最多一个小时).
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).
我正在使用 Supervisor 来运行我的队列,并且一次运行 20 个进程.我的主管配置文件如下所示:
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
在我的 duplitron-worker.log
中,我注意到 Failed: IlluminateQueueCallQueuedHandler@call
偶尔会发生,我想更好地了解究竟是什么失败了.我的 laravel.log 文件中没有任何内容(通常会出现异常).
In my duplitron-worker.log
I noticed Failed: IlluminateQueueCallQueuedHandler@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).
问题
有没有一种方便的方法可以让我详细了解导致我的工作失败的原因?
Is there a handy way for me to learn more about what is causing my job to fail?
推荐答案
在较新的 Laravel 版本中,failed_jobs
表中有一个 exception
列,其中包含您的所有信息需要.感谢 cdarken 和 Toskan 指出这一点!
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 :)
运行
php artisan queue:failed
命令来列出所有失败的作业,然后选择你想要的.记下 ID.
Run the
php artisan queue:failed
command to list all the failed jobs, and pick the one you're after. Write the ID down.
然后,确保使用 supervisorctl stop all duplitron-worker:
最后,确保 APP_DEBUG
的 .env 设置 = true.
Lastly, make sure your .env setting for APP_DEBUG
= true.
然后运行 php artisan queue:retry {step_job_1_id}
现在手动运行php 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.
祝你调试顺利:-)
相关文章