https://github.com/oefenweb/cakephp-queue
A minimalistic Queue Plugin for CakePHP
https://github.com/oefenweb/cakephp-queue
cakephp cakephp2 php plugin queue
Last synced: 8 months ago
JSON representation
A minimalistic Queue Plugin for CakePHP
- Host: GitHub
- URL: https://github.com/oefenweb/cakephp-queue
- Owner: Oefenweb
- License: mit
- Created: 2013-06-14T12:36:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-01-17T15:28:51.000Z (about 3 years ago)
- Last Synced: 2024-04-25T05:01:43.709Z (almost 2 years ago)
- Topics: cakephp, cakephp2, php, plugin, queue
- Language: PHP
- Homepage:
- Size: 241 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Queue plugin for CakePHP
[](https://travis-ci.org/Oefenweb/cakephp-queue)
[](https://travis-ci.org/Oefenweb/cakephp-queue)
[](https://codecov.io/gh/Oefenweb/cakephp-queue)
[](https://packagist.org/packages/oefenweb/cakephp-queue)
[](https://codeclimate.com/github/Oefenweb/cakephp-queue)
[](https://scrutinizer-ci.com/g/Oefenweb/cakephp-queue/?branch=master)
## Requirements
* CakePHP 2.9.0 or greater.
* PHP 7.0.0 or greater.
## Installation
Clone/Copy the files in this directory into `app/Plugin/Queue`
## Configuration
Ensure the plugin is loaded in `app/Config/bootstrap.php` by calling:
```
CakePlugin::load('Queue');
```
Ensure to configure the following lines in `app/Config/bootstrap.php`:
```
Configure::write('Queue.workers', 3);
Configure::write('Queue.sleepTime', 10);
Configure::write('Queue.gcprop', 10);
Configure::write('Queue.defaultWorkerTimeout', 2 * MINUTE);
Configure::write('Queue.defaultWorkerRetries', 4);
Configure::write('Queue.workerMaxRuntime', 0);
Configure::write('Queue.cleanupTimeout', DAY);
Configure::write('Queue.exitWhenNothingToDo', false);
Configure::write('Queue.gcOnExit', true);
```
Load schema:
```
Console/cake schema create;
```
## Usage
### Console
Run from your APP folder:
```
# Tries to call the `add()` function on a task.
Console/cake Queue.queue add ;
```
```
# Run a queue worker.
Console/cake Queue.queue runworker;
```
```
# Display some general statistics.
Console/cake Queue.queue stats;
```
```
# Manually call cleanup function to delete task data of completed tasks.
Console/cake Queue.queue clean;
```
```
# Manually call cleanup_failed function to delete task data of failed tasks.
Console/cake Queue.queue clean_failed;
```
#### Running only specific tasks per worker
You can filter "running" by type:
```
Console/cake Queue.queue runworker -t MyType,AnotherType,-ThisOneToo
Console/cake Queue.queue runworker -t "-ThisOneNot"
```
Use `-` prefix to exclude. Note that you might need to use `""` around the value then to avoid it being seen as option key.
That can be helpful when migrating servers and you only want to execute certain ones on the new system or want to test specific servers.