06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Queues 430<br />

Specifying The Job Timeout Parameter<br />

You may also set the length of time (in seconds) each job should be allowed to run:<br />

1 php artisan queue:listen --timeout=60<br />

Specifying Queue Sleep Duration<br />

In addition, you may specify the number of seconds to wait before polling for new jobs:<br />

1 php artisan queue:listen --sleep=5<br />

Note that the queue only “sleeps” if no jobs are on the queue. If more jobs are available, the queue<br />

will continue to work them without sleeping.<br />

Processing The First Job On The Queue<br />

To process only the first job on the queue, you may use the queue:work command:<br />

1 php artisan queue:work<br />

Supervisor Configuration<br />

Supervisor is a process monitor for the Linux operating system, and will automatically restart your<br />

queue:listen or queue:work commands if they fail. To install Supervisor on Ubuntu, you may use<br />

the following command:<br />

1 sudo apt-get install supervisor<br />

Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within<br />

this directory, you may create any number of configuration files that instruct supervisor how your<br />

processes should be monitored. For example, let’s create a <strong>laravel</strong>-worker.conf file that starts and<br />

monitors a queue:work process:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!