简体   繁体   English

Laravel 5.2队列-延迟不起作用

[英]Laravel 5.2 queue - Delay not working

I need your help. 我需要你的帮助。

I'm working with Laravel queue and with Linux supervisor tool (Exactly like it the documentation) 我正在使用Laravel队列和Linux主管工具(与文档完全一样)

Now I have a very weird issue. 现在我有一个很奇怪的问题。

When I use this command without delay 当我毫不延迟地使用此命令时

$job = (new SendAutoresponderEmail($poptin,$autoresponder,$data));

It's working fine. 一切正常。

But when I use the delay option 但是当我使用延迟选项

$job = (new SendAutoresponderEmail($poptin,$autoresponder,$data))->delay(60);

The job failed and not continue anymore 作业失败,不再继续

I can see the job on my failed-job table. 我可以在失败的工作表上看到工作。

Now... When I'm not working with the supervisor tool and just run the command in my terminal: 现在...当我不使用超级用户工具时,只需在终端中运行命令:

php artisan queue:listen

The command with the delay option and other queue task working fine. 带有delay选项的命令和其他队列任务正常运行。

This is my larave-worker content look like: 这是我的larave-worker内容,看起来像:

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/Poptin/artisan queue:work database --sleep=3 --tries=3 --daemon
autostart=true
autorestart=true
user=ubuntu
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/html/<project>/worker.log

What you think I need to do in order to fix it? 您认为我需要做些什么来解决它?

Also ... How can I use a different queue for a different job? 另外...如何将不同的队列用于不同的工作? like that 像那样

$job = (new SendAutoresponderEmail($poptin,$autoresponder,$data))->onQueue('autoresponder')->delay(60);

?

currently, I have only the default queue. 目前,我只有默认队列。 Where I declare others queues in my config/queue.php file? 我在config / queue.php文件中在哪里声明其他队列?

'connections' => [

    'sync' => [
        'driver' => 'sync',
    ],

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'expire' => 60,
    ],

分派你的工作

$job = (new SendAutoresponderEmail($poptin,$autoresponder,$data))->delay(60); $this->dispatch($job);

So... Eventually, I solve the issue by creating a new supervisor worker in a different connection and queue, like this: 所以...最终,我通过在不同的连接和队列中创建一个新的主管工作者来解决此问题,如下所示:

[program:autoresponder-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/<Project>/artisan queue:listen autoresponder --sleep=5 -
-tries=3
autostart=true
autorestart=true
user=ubuntu
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/<Project>/worker.log

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM