Skip to content

Commit

Permalink
Merge pull request #40 from easybib/master
Browse files Browse the repository at this point in the history
examples
  • Loading branch information
brianlmoon committed May 10, 2012
2 parents f0a0d54 + 8cf5083 commit 6529dd4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Expand Up @@ -146,3 +146,32 @@ There are some more command line options that are handy for running the daemon.
-d - If set on the command line, the manager will daemonize

-u - The user to run the daemon as. You can also use user in the ini file.

Debugging
=========

So you built an awesome worker but for some reason it dies and the `error_log` is empty?

GearmanManager makes use of the supression operator (`@`) every now and then which makes it a little harder to debug because error messages are silenced.

The solution is [Xdebug](http://xdebug.org/)'s scream and the steps to set it up are:

1. Install Xdebug
2. Configure it
3. Profit!


Installation
------------

pecl install xdebug

Configuration
-------------

Put the following into your `xdebug.ini`:

zend_extension="/path/to/where/your/xdebug.so"
xdebug.scream = 1
xdebug.show_exception_trace = 1

37 changes: 37 additions & 0 deletions pecl-client/example.php
@@ -0,0 +1,37 @@
<?php
/**
* Run the reverse function.
*
* @link http://de2.php.net/manual/en/gearman.examples-reverse.php
*/
$gmclient= new GearmanClient();

# Add default server (localhost).
$gmclient->addServer();

$function = 'reverse';
$data = 'Hello!';

do {

$result = $gmclient->do($function, $data);

switch($gmclient->returnCode()) {
case GEARMAN_WORK_DATA:
echo "Data: $result\n";
break;
case GEARMAN_WORK_STATUS:
list($numerator, $denominator)= $gmclient->doStatus();
echo "Status: $numerator/$denominator complete\n";
break;
case GEARMAN_WORK_FAIL:
echo "Failed\n";
exit;
case GEARMAN_SUCCESS:
break;
default:
echo "RET: " . $gmclient->returnCode() . "\n";
exit;
}
}
while($gmclient->returnCode() != GEARMAN_SUCCESS);

0 comments on commit 6529dd4

Please sign in to comment.