Laravel队列:工作永远运行

时间:2018-05-10 12:08:22

标签: laravel artisan laravel-queue

我对Laravel队列有一个奇怪的问题:工作。 在我的crontab中,我设置了一个像Laravel Docs

中描述的工作
* * * * * nginx php /path/to/site/artisan schedule:run >> /dev/null 2>&1

在我的app / Console / Kernel.php中,我设置了这个:

$schedule->command('queue:work')->cron('* * * * *');

在我的生产服务器上,php工匠队列:工作运行几秒钟,然后被杀死#34;。这就是我的期望。

在我的开发盒php工匠队列:工作永远运行。因此,激活cron作业会产生php进程,直到整个内存都被填满。

两个盒子都是CentOS 7.4,生产运行PHP 7.1,dev运行PHP 7.2

如下面的评论所述,我不认为cron命令是问题。

运行表单ssh:

php artisan queue:work

on dev会在生产过程中永远运行几秒钟。

1 个答案:

答案 0 :(得分:0)

You can try to run it once, this runs a single job and then quits the process.

php artisan queue:work --once=1

Or in your PHP code using the Artisan facade:

Artisan::call('queue:work', [
                    '--once' => 1, // Do NOT run it as a daemon (not a continuous function)
                    '--tries' => 1,
                    '--queue' => 'yourqueue',
                    '--timeout' => 0
                ]);
相关问题