Skip to content

Commit 271b584

Browse files
author
Rajib Ahmed
committed
Add github style syntax highlights on README file.
1 parent a1cfc29 commit 271b584

File tree

1 file changed

+83
-52
lines changed

1 file changed

+83
-52
lines changed

README.md

Lines changed: 83 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,34 @@ If you're not familiar with Composer, please see <http://getcomposer.org/>.
5151

5252
1. Add php-resque to your application's composer.json.
5353

54+
```json
55+
5456
{
5557
...
5658
"require": {
5759
"chrisboulton/php-resque": "1.2.x"
5860
},
5961
...
6062
}
63+
```
6164

6265
2. Run `composer install`.
6366

6467
3. If you haven't already, add the Composer autoload to your project's
6568
initialization file. (example)
6669

70+
```sh
6771
require 'vendor/autoload.php';
72+
```
6873

6974
## Jobs ##
7075

7176
### Queueing Jobs ###
7277

7378
Jobs are queued as follows:
7479

80+
```php
81+
7582
// Required if redis is located elsewhere
7683
Resque::setBackend('localhost:6379');
7784

@@ -80,10 +87,14 @@ Jobs are queued as follows:
8087
);
8188
Resque::enqueue('default', 'My_Job', $args);
8289

90+
```
91+
8392
### Defining Jobs ###
8493

8594
Each job should be in it's own class, and include a `perform` method.
8695

96+
```php
97+
8798
class My_Job
8899
{
89100
public function perform()
@@ -93,6 +104,8 @@ Each job should be in it's own class, and include a `perform` method.
93104
}
94105
}
95106

107+
```
108+
96109
When the job is run, the class will be instantiated and any arguments
97110
will be set as an array on the instantiated object, and are accessible
98111
via `$this->args`.
@@ -105,23 +118,27 @@ Jobs can also have `setUp` and `tearDown` methods. If a `setUp` method
105118
is defined, it will be called before the `perform` method is run.
106119
The `tearDown` method if defined, will be called after the job finishes.
107120

108-
class My_Job
109-
{
110-
public function setUp()
111-
{
112-
// ... Set up environment for this job
113-
}
114121

115-
public function perform()
116-
{
117-
// .. Run job
118-
}
122+
```php
119123

120-
public function tearDown()
121-
{
122-
// ... Remove environment for this job
123-
}
124-
}
124+
class My_Job
125+
{
126+
public function setUp()
127+
{
128+
// ... Set up environment for this job
129+
}
130+
131+
public function perform()
132+
{
133+
// .. Run job
134+
}
135+
136+
public function tearDown()
137+
{
138+
// ... Remove environment for this job
139+
}
140+
}
141+
```
125142

126143
### Tracking Job Statuses ###
127144

@@ -144,11 +161,11 @@ To fetch the status of a job:
144161
Job statuses are defined as constants in the `Resque_Job_Status` class.
145162
Valid statuses include:
146163

147-
* `Resque_Job_Status::STATUS_WAITING` - Job is still queued
148-
* `Resque_Job_Status::STATUS_RUNNING` - Job is currently running
149-
* `Resque_Job_Status::STATUS_FAILED` - Job has failed
150-
* `Resque_Job_Status::STATUS_COMPLETE` - Job is complete
151-
* `false` - Failed to fetch the status - is the token valid?
164+
* `Resque_Job_Status::STATUS_WAITING` - Job is still queued
165+
* `Resque_Job_Status::STATUS_RUNNING` - Job is currently running
166+
* `Resque_Job_Status::STATUS_FAILED` - Job has failed
167+
* `Resque_Job_Status::STATUS_COMPLETE` - Job is complete
168+
* `false` - Failed to fetch the status - is the token valid?
152169

153170
Statuses are available for up to 24 hours after a job has completed
154171
or failed, and are then automatically expired. A status can also
@@ -177,7 +194,9 @@ It's your responsibility to tell the worker which file to include to get
177194
your application underway. You do so by setting the `APP_INCLUDE` environment
178195
variable:
179196

197+
```sh
180198
$ QUEUE=file_serve APP_INCLUDE=../application/init.php php bin/resque
199+
```
181200

182201
*Pro tip: Using Composer? More than likely, you don't need to worry about
183202
`APP_INCLUDE`, because hopefully Composer is responsible for autoloading
@@ -192,8 +211,10 @@ The port supports the same environment variables for logging to STDOUT.
192211
Setting `VERBOSE` will print basic debugging information and `VVERBOSE`
193212
will print detailed information.
194213

214+
```sh
195215
$ VERBOSE QUEUE=file_serve bin/resque
196216
$ VVERBOSE QUEUE=file_serve bin/resque
217+
```
197218

198219
### Priorities and Queue Lists ###
199220

@@ -204,7 +225,9 @@ checked in.
204225

205226
As per the original example:
206227

228+
```sh
207229
$ QUEUE=file_serve,warm_cache bin/resque
230+
```
208231

209232
The `file_serve` queue will always be checked for new jobs on each
210233
iteration before the `warm_cache` queue is checked.
@@ -214,21 +237,27 @@ iteration before the `warm_cache` queue is checked.
214237
All queues are supported in the same manner and processed in alphabetical
215238
order:
216239

240+
```sh
217241
$ QUEUE=* bin/resque
242+
```
218243

219244
### Running Multiple Workers ###
220245

221246
Multiple workers ca be launched and automatically worked by supplying
222247
the `COUNT` environment variable:
223248

224-
$ COUNT=5 bin/resque
249+
```sh
250+
$ COUNT=5 bin/resque
251+
```
225252

226253
### Custom prefix ###
227254

228255
When you have multiple apps using the same Redis database it is better to
229256
use a custom prefix to separate the Resque data:
230257

231-
$ PREFIX=my-app-name bin/resque
258+
```sh
259+
$ PREFIX=my-app-name bin/resque
260+
```
232261

233262
### Forking ###
234263

@@ -245,11 +274,11 @@ the job.
245274
Signals also work on supported platforms exactly as in the Ruby
246275
version of Resque:
247276

248-
* `QUIT` - Wait for child to finish processing then exit
249-
* `TERM` / `INT` - Immediately kill child then exit
250-
* `USR1` - Immediately kill child but don't exit
251-
* `USR2` - Pause worker, no new jobs will be processed
252-
* `CONT` - Resume worker.
277+
* `QUIT` - Wait for child to finish processing then exit
278+
* `TERM` / `INT` - Immediately kill child then exit
279+
* `USR1` - Immediately kill child but don't exit
280+
* `USR2` - Pause worker, no new jobs will be processed
281+
* `CONT` - Resume worker.
253282

254283
### Process Titles/Statuses ###
255284

@@ -274,14 +303,16 @@ You listen in on events (as listed below) by registering with `Resque_Event`
274303
and supplying a callback that you would like triggered when the event is
275304
raised:
276305

306+
```sh
277307
Resque_Event::listen('eventName', [callback]);
308+
```
278309

279310
`[callback]` may be anything in PHP that is callable by `call_user_func_array`:
280311

281-
* A string with the name of a function
282-
* An array containing an object and method to call
283-
* An array containing an object and a static method to call
284-
* A closure (PHP 5.3)
312+
* A string with the name of a function
313+
* An array containing an object and method to call
314+
* An array containing an object and a static method to call
315+
* A closure (PHP 5.3)
285316

286317
Events may pass arguments (documented below), so your callback should accept
287318
these arguments.
@@ -358,24 +389,24 @@ Called after a job has been queued using the `Resque::enqueue` method. Arguments
358389

359390
## Contributors ##
360391

361-
* chrisboulton
362-
* thedotedge
363-
* hobodave
364-
* scraton
365-
* KevBurnsJr
366-
* jmathai
367-
* dceballos
368-
* patrickbajao
369-
* andrewjshults
370-
* warezthebeef
371-
* d11wtq
372-
* hlegius
373-
* salimane
374-
* humancopy
375-
* pedroarnal
376-
* chaitanyakuber
377-
* maetl
378-
* Matt Heath
379-
* jjfrey
380-
* scragg0x
381-
* ruudk
392+
* chrisboulton
393+
* thedotedge
394+
* hobodave
395+
* scraton
396+
* KevBurnsJr
397+
* jmathai
398+
* dceballos
399+
* patrickbajao
400+
* andrewjshults
401+
* warezthebeef
402+
* d11wtq
403+
* hlegius
404+
* salimane
405+
* humancopy
406+
* pedroarnal
407+
* chaitanyakuber
408+
* maetl
409+
* Matt Heath
410+
* jjfrey
411+
* scragg0x
412+
* ruudk

0 commit comments

Comments
 (0)