You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.1.x数据库队列任务未执行问题排查求助

Hey Ben, let's dig into why your production queue is stacking up even though you've got the process running in Forge. Since your test site works fine, the issue is likely tied to production-specific config, code, or process state—here's what to check next:

1. Verify Queue Process Environment & Configuration
  • Double-check the environment variables for your Forge daemon: Is the queue process loading the correct production .env file? Sometimes after deploying, the daemon might still be using old config values (like wrong Redis/database credentials, or a mismatched QUEUE_CONNECTION). Compare the daemon command in Forge (e.g., php artisan queue:work redis --queue=default) to your test site's setup and your production .env settings.
  • Test the queue driver connection: If using Redis, run redis-cli ping on the server to confirm connectivity. For database-driven queues, check that the jobs table has pending tasks, and that the queue process has permission to access the production DB. Run php artisan queue:work --once manually—it'll attempt to process one task and spit out any immediate errors.
2. Check for Code Compatibility Issues
  • Audit your recent deployment: Did you add new job classes or modify existing task logic? Make sure all production dependencies are installed with composer install --no-dev—sometimes test-specific packages are missing in production. Also, run composer dump-autoload to refresh autoloading, in case job class paths or namespaces changed.
  • Review failure logs: Check Laravel's storage/logs/laravel.log or the Forge daemon logs for error messages. Uncaught exceptions in jobs can cause processes to hang or tasks to retry repeatedly, leading to a backlog. If you've enabled failed job tracking, look at the failed_jobs table for clues about which tasks are failing.
3. Confirm Queue Process Health & Server Resources
  • Ensure the queue process is actually running: Daemons can sometimes crash or get stuck without showing as "stopped" in Forge. SSH into the server and run ps aux | grep queue:work to see active processes—check the start time to confirm it's running post-deployment. If it's an old process, restart the daemon in Forge.
  • Check server resource limits: Is the production server low on CPU, memory, or disk space? Queue processes need adequate resources to run—memory exhaustion, for example, can crash the worker. Use top to monitor CPU/memory usage, and df -h to check disk space. If using Redis, verify it hasn't hit its memory limit (which would block task processing).
4. Validate Queue Names & Priority Settings
  • Match queue names between jobs and workers: If your tasks are dispatched to a specific queue (e.g., dispatch(new SendEmail)->onQueue('emails')), make sure your Forge daemon is listening to that queue with --queue=emails,default (order matters for priority). If the worker only listens to default, tasks in other queues will pile up.
  • Check retry delays and limits: If jobs keep failing, Laravel will retry them based on QUEUE_RETRY_AFTER in .env and $tries/$maxExceptions in your job classes. Excessive delays can make it look like tasks aren't being processed—adjust these settings if needed, or manually delete stuck failed jobs to clear the backlog.

内容的提问来源于stack exchange,提问作者Ben

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:14:57