windows - Laravel 命令队列:工作在 Windows 中冻结
问题描述
我创建了一个事件,当触发一个侦听器时,它会调度一个延迟时间为 20 秒的作业。该工作的唯一目的是在用户尝试登录时将电子邮件发送给用户。问题是当我跑步时
php artisan queue:work
终端没有显示任何内容,也没有任何工作被延迟。但是电子邮件会发送给用户。有关更多信息,我正在使用望远镜进行调试。我的驱动程序是数据库。[输出][1]
我的工作代码
class sendEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public $user;
public function __construct($user)
{
$this->user=$user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
\Mail::to($this->user)->send(new \App\Mail\subscriptionLetters());
}
}
派遣工作时
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param UserLoggedIn $event
* @return void
*/
public function handle(UserLoggedIn $event)
{
\App\Jobs\sendEmail::dispatch($event->user)->delay(Carbon::now()->addSeconds(20));
}
}
```[command in terminanl][2]
[1]: https://i.stack.imgur.com/UDADW.png
[2]: https://i.stack.imgur.com/V8EFm.png
解决方案
跑
php artisan config:clear
然后在运行之后关闭laravel的开发服务器
php artisan serve
现在你会看到你的
php artisan queue:work
工作,记住运行队列:在单独的终端工作