The PHP Gearman Daemons Manager library allows running gearman workers as deamons using supervisord or using a built it php process manager. The library is framework independent and can be easily integrated into any project.
- PHP >= 5.3
The easiest way to work with this package is when it's installed as a Composer package inside your project. Composer isn't strictly required, but makes life a lot easier.
If you're not familiar with Composer, please see http://getcomposer.org/.
-
Add php_gearman_daemons to your application's composer.json.
{ ... "require": { "aporat/php_gearman_daemons": "dev-master" }, ... }
-
Run
php composer install
. -
If you haven't already, add the Composer autoload to your project's initialization file. (example)
require 'vendor/autoload.php';
<?php
use \GearmanDaemons\WorkerAbstract;
class Worker_DoPrint extends WorkerAbstract {
protected $_registerFunction = 'DoPrint';
protected function _perform() {
$body = unserialize($this->getWorkload());
echo 'Printing...';
}
}
yum -y install gcc* mysql55-devel boost-devel libevent-devel libuuid-devel
wget https://launchpad.net/gearmand/1.2/1.1.4/+download/gearmand-1.1.4.tar.gz
tar zxvf gearmand-1.1.4.tar.gz
cd gearmand-1.1.4 && ./configure && make && make install
pecl install gearman
echo "extension=gearman.so" >> /etc/php.ini
pecl install proctitle
echo "extension=proctitle.so" >> /etc/php.ini
yum install python-setuptools
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf