示例#1
0
/**
* See if we can talk to beanstalkd
* 
*/
function CheckBeanstalkd()
{
    global $settings;
    $ret = false;
    require_once './lib/beanstalkd/pheanstalk_init.php';
    $pheanstalk = new Pheanstalk_Pheanstalk($settings['beanstalkd']);
    if ($pheanstalk->getConnection()->isServiceListening()) {
        $id = $pheanstalk->putInTube('wpt.installtest', "test");
        $jobStats = $pheanstalk->statsJob($id);
        $tubeStats = $pheanstalk->statsTube('wpt.installtest');
        $job = $pheanstalk->reserveFromTube('wpt.installtest', 0);
        if ($job !== false && $job->getData() == 'test') {
            $ret = true;
        }
        $pheanstalk->delete($job);
    }
    return $ret;
}