0

I have configured a laravel queue to send emails, and it used to work fine sending the emails immediately.

I also used laravel task scheduler and configured the queue:listen to be executed every minute, resulting in the server crashing because cron job was calling the queue:work loop over and over again.... The site crashed. And it was the live site of the client, so the issue is pretty serious.

The hosting company modified my laravel cron job to run every 5 minutes. And since it crashed, all mails now stay in the database and the database queue doesn't work at all. I guess the process is not running at all.

I have these questions:

  • How do I execute the stacked queue records in the database?
  • How do I make the database queues work again?
  • How configure the cron job & laravel schedule to work properly.

NOTE: I want it working with the database driver and NOT with redis or sync or something else, so please stay focused on the database driver, thanks.

4

3 回答 3

2

laravel 任务调度器并配置 queue:listen 每分钟执行一次

这是错误的。你永远不应该通过 cron 调度程序调用queue:listen,否则你会得到意想不到的行为,比如发生在你身上的事情。

您应该将 queue:listen 配置为永远作为守护进程运行。一旦队列工作者运行——它将永远运行并根据需要处理作业。您可以使用Supervisor来确保它保持运行。

于 2017-05-06T22:56:25.343 回答
1

我认为问题在于该queue:listen命令实际上每分钟执行一次。这不应该发生。它只应在特定时刻未在侦听时执行。因此,应该检查侦听器是否正在运行。看到这个要点,应该对你有用。

要从数据库执行所有挂起队列任务,请尝试:

php artisan queue:restart

和:

php artisan queue:work

希望这可以帮助。

于 2017-05-04T10:47:15.183 回答
0

在 Laravel 8 中(在以前的版本中不确定)

php artisan queue:work --stop-when-empty

这个命令可以毫无问题地“croned”。

于 2021-11-09T09:36:47.133 回答