I am running Laravel 5 and I am trying to get a command in the queue. I run it:
Queue::push( new MyCommand() );
To create team I, I did:
php artisan make:command --queued MyCommand
MyCommand contains sleep(20)andfile_put_contents('test.txt','I work!')
Command line I run:
beanstalkd -l 127.0.0.1 -p 11301 &
php artisan queue:listen &
And config / queue.php matters:
'default' => env('QUEUE_DRIVER', 'beanstalkd'),
...
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost:11301',
'queue' => 'default',
'ttr' => 60,
],
When I click the code from the browser, it freezes for 20 seconds and discards the file before terminating, rather than returning immediately.
Is there anything else I need to do for the correct command queue in the background?
source
share