-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated readme. + is not needed as we run queue/run instead of queue/…
…exec
- Loading branch information
Oliver Stark
committed
Oct 16, 2017
1 parent
4cd0f06
commit fc10460
Showing
3 changed files
with
44 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,41 @@ | ||
# Async (Background) Queue | ||
|
||
Inpired by this discussion | ||
https://github.com/craftcms/cms/issues/1952 | ||
With Craft's job queue you can run heavy tasks in the background. Unfortunately, this is not entirely true, when `runQueueAutomatically => true` (default), the job queue is handled by a ajax (FPM) call. | ||
With many jobs in the queue and limited PHP-FPM processes this break your site. | ||
|
||
This plugin replaces Craft's default queue handler and moves queue execution to a non-blocking background process. | ||
The command `craft queue/run` gets executed right after you push a Job to the queue`. | ||
|
||
[Here](https://github.com/craftcms/cms/issues/1952) you can find the initial discussion I started at `craftcms/cms`. | ||
|
||
## Installation | ||
|
||
1. Install with Composer via `composer require ostark/craft-async-queue` from your project directory | ||
2. Install plugin with this command `php ./craft install/plugin async-queue` or in the Craft Control Panel under Settings > Plugins | ||
|
||
## Configuration (optional) | ||
|
||
The plugin expects the `php` binary in `/usr/bin/`. If the binary is located somewhere else, you can overwrite the default with the `PATH_PHP_BINARY ENV var, e.g. in your .env file like this: | ||
``` | ||
PATH_PHP_BINARY=/usr/local/Cellar/php71/7.1.0_11/bin/php' | ||
``` | ||
|
||
## Under the hood: Process list | ||
|
||
**Empty queue** (only php-fpm master is running) | ||
``` | ||
$ ps auxf | grep php | ||
root 2953 0.0 0.0 399552 13520 ? Ss 12:27 0:00 php-fpm: master process (/etc/php/fpm.conf) | ||
```` | ||
|
||
**New job pushed** (php-fpm master + child + /usr/bin/php daemon started) | ||
``` | ||
$ ps auxf | grep php | ||
root 2953 0.0 0.0 399552 13520 ? Ss 12:27 0:00 php-fpm: master process (/etc/php/fpm.conf) | ||
app 3031 2.2 0.2 718520 45992 ? S 12:31 0:00 \_ php-fpm: pool www | ||
app 3033 1.2 0.2 280936 32808 ? S 12:31 0:00 /usr/bin/php craft queue/run | ||
app 3034 0.0 0.0 4460 784 ? S 12:31 0:00 \_ sh -c /usr/bin/php craft queue/exec "1234" "0" "1" | ||
app 3035 1.2 0.2 280928 32280 ? S 12:31 0:00 \_ /usr/bin/php craft queue/exec 1234 0 1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters