从作业队列内部广播laravel事件

cwtwac6a  于 2021-06-17  发布在  Mysql
关注(0)|答案(0)|浏览(168)

几天过去了,我一直在广播活动。
我有一个弹性豆茎装置推进器配置如下 BROADCAST_DRIVER=pusher QUEUE_DRIVER=database 管理一个拉威尔的主管。
使用laravel 5.5版
工作就是 ConvertVideoForStreaming 一件事 VideoProcessingStarted 当作业在后端开始处理时,将调用此事件。
它的工作原理很好,我尝试它在本地使用 php artisan queue:work --timeout=0 --tries=1 但是当我尝试使用supervisor时,作业会被执行,但是从作业内部调用的事件不会被调度。
我仍然不知道它为什么要这样做,在本地使用artisan命令,但不使用运行在aws服务器上的主管。
elastic beanstalk的管理器配置:

[supervisord]
   logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
   logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
   logfile_backups=10           ; (num of main logfile rotation backups;default 10)
   loglevel=info                ; (log level;default info; others: debug,warn,trace)
   pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
   nodaemon=false               ; (start in foreground if true;default false)
   minfds=1024                  ; (min. avail startup file descriptors;default 1024)
   minprocs=20                 ; (min. avail process descriptors;default 200)

   [rpcinterface:supervisor]
   supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

   [supervisorctl]
   serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket

   [program:queue]
   command=php artisan queue:work database --tries=3 --timeout=0 --queue=notifications,default
   directory=/var/app/current
   stdout_logfile=/var/app/current/storage/logs/supervisor.log
   redirect_stderr=true

事件class:videoprocessingstarted

class VideoProcessingStarted implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $videoID;
    public $offerID;
//    public $queue = 'notifications'; //Queue Name

    public function __construct($video)
    {
        $this->videoID = $video->id;
        $this->offerID = $video->offer->id;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('videos-processing.'.$this->videoID);
    }
}

工作:放弃追求

class ConvertVideoForStreaming implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $video;
    public $disk;
    public $dateTimeStringNow;

    public function __construct(OfferLibrary $video,$disk)
    {
        $this->video = $video;
        $this->disk = $disk;
        $this->dateTimeStringNow = Carbon::now()->toDateTimeString();
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        /*
         * TotalJobStatuses
         * 1 - queue (meaning processing is pending)
         * 2 - processing (job has been started and in progress)
         * 3 - success (job has been processed and got completed successfully)
         * 4 - failed (job has been processed, but failed to complete)
         * */
        event(new VideoProcessingStarted($this->video));
        event(new VideoProcessingFailed($this->video->id));
        event(new VideoProcessingQueued($this->video));
        \Log::info('this should work, why not working, i dont know.::'.$this->video->id);
        return null;
}

作业中的事件被完全忽略,没有错误。

event(new VideoProcessingStarted($this->video));
            event(new VideoProcessingFailed($this->video->id));
            event(new VideoProcessingQueued($this->video));

但最后一行日志信息将被执行,并记录在laravel.log文件中

\Log::info('this should work, why not working, i dont know.::'.$this->video->id);

我不知道为什么,但是事件在本地机器上运行得很好,但是当我在aws服务器的supervisor上尝试时,它们在内部作业中被忽略了。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题