Прошло много дней, я застрял в вещательных событиях.
У меня есть - AWS упругий бобовый стебель.- Толкатель настроен на следующие конфигурации
BROADCAST_DRIVER=pusher
QUEUE_DRIVER=database
Это событие вызывается, так как задание запускается в бэкэнде.
Он работает нормально, я пробую его локально, используя
php artisan queue:work --timeout=0 --tries=1
Но когда я пытаюсь использовать супервизор, задание выполняется, но событие, вызванное изнутри задания, не отправляется.
Я до сих пор не уверен, почему это происходит, работайте локально с командой artisan, но не с супервизором, работающим на сервере aws.
Конфигурации супервизора для эластичного 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
Класс события: 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);
}
}
Задание: ConvertVideoForStreaming
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, они просто игнорируются из-за внутренних заданий.