09/24/13

gearmand php Worker & Client

Worker.php
<?php
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction(“sendMsn”, “sendMSN_function”);
while ($worker->work());

function sendMSN_function($job)
{
$subject = ucwords(strtolower($job->workload()));
exec(“echo $subject >>/opt/phpdba/www/html/cacti/plugins/thold/alter.log”);
exec(“sh /opt/phpdba/sendMsg/sendMsg.sh >>/opt/sendMsg/sendmsg.log 2>&1″);
return ;
}
?>

Client.php

<?php
$client= new GearmanClient();
$client->addServer();
$client->do(“sendMsn”, $subject);
?>