【问题标题】:Laravel command queue:work freezes in windowsLaravel 命令队列:工作在 Windows 中冻结
【发布时间】:2019-10-18 06:33:43
【问题描述】:

我创建了一个事件,当触发一个监听器时,它会调度一个延迟时间为 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

【问题讨论】:

    标签: windows laravel terminal command


    【解决方案1】:

    运行

    php artisan config:clear
    

    然后关闭 laravel 的开发服务器 之后运行

    php artisan serve
    

    现在你会看到你的

    php artisan queue:work
    

    工作,记住运行队列:在单独的终端工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-03
      • 2016-10-01
      • 1970-01-01
      • 2018-06-20
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      • 2018-07-30
      相关资源
      最近更新 更多