mirror of
https://github.com/idanoo/php-resque.git
synced 2024-11-22 08:15:14 +00:00
Add github style syntax highlights on README file.
This commit is contained in:
parent
a1cfc292d4
commit
271b584957
31
README.md
31
README.md
@ -51,6 +51,8 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
|
|
||||||
1. Add php-resque to your application's composer.json.
|
1. Add php-resque to your application's composer.json.
|
||||||
|
|
||||||
|
```json
|
||||||
|
|
||||||
{
|
{
|
||||||
...
|
...
|
||||||
"require": {
|
"require": {
|
||||||
@ -58,13 +60,16 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
},
|
},
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
2. Run `composer install`.
|
2. Run `composer install`.
|
||||||
|
|
||||||
3. If you haven't already, add the Composer autoload to your project's
|
3. If you haven't already, add the Composer autoload to your project's
|
||||||
initialization file. (example)
|
initialization file. (example)
|
||||||
|
|
||||||
|
```sh
|
||||||
require 'vendor/autoload.php';
|
require 'vendor/autoload.php';
|
||||||
|
```
|
||||||
|
|
||||||
## Jobs ##
|
## Jobs ##
|
||||||
|
|
||||||
@ -72,6 +77,8 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
|
|||||||
|
|
||||||
Jobs are queued as follows:
|
Jobs are queued as follows:
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
// Required if redis is located elsewhere
|
// Required if redis is located elsewhere
|
||||||
Resque::setBackend('localhost:6379');
|
Resque::setBackend('localhost:6379');
|
||||||
|
|
||||||
@ -80,10 +87,14 @@ Jobs are queued as follows:
|
|||||||
);
|
);
|
||||||
Resque::enqueue('default', 'My_Job', $args);
|
Resque::enqueue('default', 'My_Job', $args);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
### Defining Jobs ###
|
### Defining Jobs ###
|
||||||
|
|
||||||
Each job should be in it's own class, and include a `perform` method.
|
Each job should be in it's own class, and include a `perform` method.
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
class My_Job
|
class My_Job
|
||||||
{
|
{
|
||||||
public function perform()
|
public function perform()
|
||||||
@ -93,6 +104,8 @@ Each job should be in it's own class, and include a `perform` method.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
When the job is run, the class will be instantiated and any arguments
|
When the job is run, the class will be instantiated and any arguments
|
||||||
will be set as an array on the instantiated object, and are accessible
|
will be set as an array on the instantiated object, and are accessible
|
||||||
via `$this->args`.
|
via `$this->args`.
|
||||||
@ -105,6 +118,9 @@ Jobs can also have `setUp` and `tearDown` methods. If a `setUp` method
|
|||||||
is defined, it will be called before the `perform` method is run.
|
is defined, it will be called before the `perform` method is run.
|
||||||
The `tearDown` method if defined, will be called after the job finishes.
|
The `tearDown` method if defined, will be called after the job finishes.
|
||||||
|
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
class My_Job
|
class My_Job
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
@ -122,6 +138,7 @@ The `tearDown` method if defined, will be called after the job finishes.
|
|||||||
// ... Remove environment for this job
|
// ... Remove environment for this job
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Tracking Job Statuses ###
|
### Tracking Job Statuses ###
|
||||||
|
|
||||||
@ -177,7 +194,9 @@ It's your responsibility to tell the worker which file to include to get
|
|||||||
your application underway. You do so by setting the `APP_INCLUDE` environment
|
your application underway. You do so by setting the `APP_INCLUDE` environment
|
||||||
variable:
|
variable:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ QUEUE=file_serve APP_INCLUDE=../application/init.php php bin/resque
|
$ QUEUE=file_serve APP_INCLUDE=../application/init.php php bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
*Pro tip: Using Composer? More than likely, you don't need to worry about
|
*Pro tip: Using Composer? More than likely, you don't need to worry about
|
||||||
`APP_INCLUDE`, because hopefully Composer is responsible for autoloading
|
`APP_INCLUDE`, because hopefully Composer is responsible for autoloading
|
||||||
@ -192,8 +211,10 @@ The port supports the same environment variables for logging to STDOUT.
|
|||||||
Setting `VERBOSE` will print basic debugging information and `VVERBOSE`
|
Setting `VERBOSE` will print basic debugging information and `VVERBOSE`
|
||||||
will print detailed information.
|
will print detailed information.
|
||||||
|
|
||||||
|
```sh
|
||||||
$ VERBOSE QUEUE=file_serve bin/resque
|
$ VERBOSE QUEUE=file_serve bin/resque
|
||||||
$ VVERBOSE QUEUE=file_serve bin/resque
|
$ VVERBOSE QUEUE=file_serve bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
### Priorities and Queue Lists ###
|
### Priorities and Queue Lists ###
|
||||||
|
|
||||||
@ -204,7 +225,9 @@ checked in.
|
|||||||
|
|
||||||
As per the original example:
|
As per the original example:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ QUEUE=file_serve,warm_cache bin/resque
|
$ QUEUE=file_serve,warm_cache bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
The `file_serve` queue will always be checked for new jobs on each
|
The `file_serve` queue will always be checked for new jobs on each
|
||||||
iteration before the `warm_cache` queue is checked.
|
iteration before the `warm_cache` queue is checked.
|
||||||
@ -214,21 +237,27 @@ iteration before the `warm_cache` queue is checked.
|
|||||||
All queues are supported in the same manner and processed in alphabetical
|
All queues are supported in the same manner and processed in alphabetical
|
||||||
order:
|
order:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ QUEUE=* bin/resque
|
$ QUEUE=* bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
### Running Multiple Workers ###
|
### Running Multiple Workers ###
|
||||||
|
|
||||||
Multiple workers ca be launched and automatically worked by supplying
|
Multiple workers ca be launched and automatically worked by supplying
|
||||||
the `COUNT` environment variable:
|
the `COUNT` environment variable:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ COUNT=5 bin/resque
|
$ COUNT=5 bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
### Custom prefix ###
|
### Custom prefix ###
|
||||||
|
|
||||||
When you have multiple apps using the same Redis database it is better to
|
When you have multiple apps using the same Redis database it is better to
|
||||||
use a custom prefix to separate the Resque data:
|
use a custom prefix to separate the Resque data:
|
||||||
|
|
||||||
|
```sh
|
||||||
$ PREFIX=my-app-name bin/resque
|
$ PREFIX=my-app-name bin/resque
|
||||||
|
```
|
||||||
|
|
||||||
### Forking ###
|
### Forking ###
|
||||||
|
|
||||||
@ -274,7 +303,9 @@ You listen in on events (as listed below) by registering with `Resque_Event`
|
|||||||
and supplying a callback that you would like triggered when the event is
|
and supplying a callback that you would like triggered when the event is
|
||||||
raised:
|
raised:
|
||||||
|
|
||||||
|
```sh
|
||||||
Resque_Event::listen('eventName', [callback]);
|
Resque_Event::listen('eventName', [callback]);
|
||||||
|
```
|
||||||
|
|
||||||
`[callback]` may be anything in PHP that is callable by `call_user_func_array`:
|
`[callback]` may be anything in PHP that is callable by `call_user_func_array`:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user