Exemple #1
0
$sphinxServer = null;
require_once $configFile;
define('ROOT_DIR', realpath(dirname(__FILE__) . '/../../../'));
require_once ROOT_DIR . '/infra/bootstrap_base.php';
require_once ROOT_DIR . '/infra/KAutoloader.php';
require_once ROOT_DIR . '/alpha/config/kConf.php';
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "propel", "*"));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"));
KAutoloader::setClassMapFilePath(kConf::get("cache_root_path") . '/sphinx/classMap.cache');
KAutoloader::register();
error_reporting(E_ALL);
KalturaLog::setLogger(new KalturaStdoutLogger());
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$serverLastLogs = SphinxLogServerPeer::retrieveByServer($sphinxServer);
$lastLogs = array();
foreach ($serverLastLogs as $serverLastLog) {
    $lastLogs[$serverLastLog->getDc()] = $serverLastLog;
}
$sphinxLogs = SphinxLogPeer::retrieveByLastId($lastLogs);
while (true) {
    while (!count($sphinxLogs)) {
        sleep(1);
        $sphinxLogs = SphinxLogPeer::retrieveByLastId($lastLogs);
    }
    $sphinxCon = null;
    try {
        $sphinxCon = DbManager::createSphinxConnection($sphinxServer);
    } catch (Exception $e) {
        KalturaLog::err($e->getMessage());
Exemple #2
0
}
$pid = $systemSettings['LOG_DIR'] . '/populate.pid';
if (file_exists($pid)) {
    KalturaLog::err("Scheduler already running - pid[" . file_get_contents($pid) . "]");
    exit(1);
}
file_put_contents($pid, getmypid());
$dbConf = kConf::getDB();
DbManager::setConfig($dbConf);
DbManager::initialize();
$limit = 1000;
// The number of sphinxLog records we want to query
$gap = 500;
// The gap from 'getLastLogId' we want to query
$sphinxReadConn = myDbHelper::getConnection(myDbHelper::DB_HELPER_CONN_SPHINX_LOG_READ);
$serverLastLogs = SphinxLogServerPeer::retrieveByServer($sphinxServer, $sphinxReadConn);
$lastLogs = array();
$handledRecords = array();
foreach ($serverLastLogs as $serverLastLog) {
    $lastLogs[$serverLastLog->getDc()] = $serverLastLog;
    $handledRecords[$serverLastLog->getDc()] = array();
}
while (true) {
    $sphinxLogs = SphinxLogPeer::retrieveByLastId($lastLogs, $gap, $limit, $handledRecords, $sphinxReadConn);
    while (!count($sphinxLogs)) {
        $skipExecutedUpdates = true;
        sleep(1);
        $sphinxLogs = SphinxLogPeer::retrieveByLastId($lastLogs, $gap, $limit, $handledRecords, $sphinxReadConn);
    }
    $sphinxCon = null;
    try {