I'm running Laravel 5 and I'm trying to get queue a command. I'm kicking it off by running:
Queue::push( new MyCommand() );
To create I command, I did:
php artisan make:command --queued MyCommand
MyCommand contains a sleep(20)
and file_put_contents('test.txt','I work!')
Command-line I'm running:
beanstalkd -l 127.0.0.1 -p 11301 &
php artisan queue:listen &
And config/queue.php is set to:
'default' => env('QUEUE_DRIVER', 'beanstalkd'),
...
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost:11301',
'queue' => 'default',
'ttr' => 60,
],
When I hit the code from the browser, it hangs for 20 seconds and drops the file before completing, instead of returning immediately.
Is there something else I need to do to properly queue a command in the background?
Make sure, you don't have any QUEUE_DRIVER
value other than beanstalkd
set in the .env
file. The env()
method:
'default' => env('QUEUE_DRIVER', 'beanstalkd'),
will first search for that key in the current eviroment loaded variables, and if there are no matches, it will fallback to the beanstalkd
value passed as the second parameter.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.