我一直在Laravel的队列中添加作业,但只有当我进入服务器并运行以下命令时它们才会运行:
php artisan queue:listen --tries 1 --timeout=60
我需要让队列不断运行,而不依赖于上面的命令行监听器。队列正在通过redis运行,到目前为止我唯一的配置是:
config.php
'queue' =>
array (
'default' => 'redis',
'connections' =>
array (
'sync' =>
array (
'driver' => 'sync',
),
'database' =>
array (
'driver' => 'database',
'table' => 'laravel_jobs',
'queue' => 'default',
'expire' => 60,
),
'beanstalkd' =>
array (
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
),
'sqs' =>
array (
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'queue' => 'your-queue-url',
'region' => 'us-east-1',
),
'iron' =>
array (
'driver' => 'iron',
'host' => 'mq-aws-us-east-1.iron.io',
'token' => 'your-token',
'project' => 'your-project-id',
'queue' => 'your-queue-name',
'encrypt' => true,
),
'redis' =>
array (
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
),
),
'failed' =>
array (
'database' => 'mysql',
'table' => 'laravel_failed_jobs',
),
),
并在我的.env文件中:
QUEUE_DRIVER=redis
我觉得我必须配置错误。
答案 0 :(得分:0)
我还没有尝试过,但我相信如果您使用cron运行此代码段,那么事情就会得到解决。
Artisan::call('queue:work')