Patrick Heppler
Patrick Heppler

Reputation: 181

Laravel queue:work runs forever

I have a weird issue with Laravel queue:work. In my crontab I setup a job like described in Laravel Docs

* * * * * nginx php /path/to/site/artisan schedule:run >> /dev/null 2>&1

And in my app/Console/Kernel.php I setup this:

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

On my production server php artisan queue:work runs for a few seconds and gets "killed". Thats what I expect.

On my dev box php artisan queue:work runs forever. So activating the cron job spawns php processes until the whole memory is filled up.

Both boxes are CentOS 7.4, production runs PHP 7.1 and dev runs PHP 7.2

As said in the comment below, I don't think that the cron command is the issue.

Running form ssh:

php artisan queue:work

on dev runs forever on production a few seconds.

Upvotes: 2

Views: 2151

Answers (1)

Flame
Flame

Reputation: 7638

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
                ]);

Upvotes: 1

Related Questions