Esempio n. 1
0
 protected static function init()
 {
     if (self::$cacheVersion) {
         return;
     }
     parent::init();
     // check for the reload file
     $cacheDir = self::$envMap['cache_root_path'];
     $reloadFileExists = file_exists("{$cacheDir}/base.reload");
     // fetch the cache version from APC
     $fileHash = md5(realpath(__FILE__));
     $cacheVersionKey = self::APC_CACHE_MAP . $fileHash;
     if (!$reloadFileExists && function_exists('apc_fetch')) {
         self::$cacheVersion = apc_fetch($cacheVersionKey);
         if (self::$cacheVersion) {
             self::$cacheKey = 'kConf-' . self::$cacheVersion;
             return;
         }
     }
     // no cache version in APC - create a new one
     self::$cacheVersion = substr(time(), -6) . substr($fileHash, 0, 4);
     self::$cacheKey = 'kConf-' . self::$cacheVersion;
     // save the cache version
     if (function_exists('apc_store') && PHP_SAPI != 'cli') {
         $res = apc_store($cacheVersionKey, self::$cacheVersion);
         if ($reloadFileExists && $res) {
             $deleted = @unlink("{$cacheDir}/base.reload");
             error_log("Base configuration reloaded");
             if (!$deleted) {
                 error_log("Failed to delete base.reload file");
             }
         }
     }
 }
Esempio n. 2
0
 public function Infra_InfraLoader(Zend_Config $config = null)
 {
     $infaFolder = null;
     $pluginsFolder = null;
     $cachePath = null;
     if ($config) {
         if (isset($config->cachePath)) {
             $cachePath = $config->cachePath;
         }
         if (isset($config->infaFolder)) {
             $infaFolder = $config->infaFolder;
         }
         if (isset($config->pluginsFolder)) {
             $pluginsFolder = $config->pluginsFolder;
         }
     }
     if (!$infaFolder) {
         $infaFolder = realpath(dirname(__FILE__) . '/../../infra/');
     }
     if (!$pluginsFolder) {
         $pluginsFolder = realpath(dirname(__FILE__) . '/../../plugins/');
     }
     if (!$cachePath) {
         $cachePath = kEnvironment::get("cache_root_path") . '/infra/classMap.cache';
     }
     require_once $infaFolder . DIRECTORY_SEPARATOR . 'KAutoloader.php';
     require_once $infaFolder . DIRECTORY_SEPARATOR . 'kEnvironment.php';
     KAutoloader::setClassPath(array($infaFolder . DIRECTORY_SEPARATOR . '*'));
     KAutoloader::addClassPath(KAutoloader::buildPath($pluginsFolder, '*'));
     KAutoloader::setClassMapFilePath($cachePath);
     KAutoloader::register();
 }
Esempio n. 3
0
 protected static function init()
 {
     if (self::$envMap) {
         return;
     }
     $appDir = realpath(__DIR__ . '/..');
     $cacheDir = "{$appDir}/cache";
     self::$envMap = array('cache_root_path' => "{$cacheDir}/", 'general_cache_dir' => "{$cacheDir}/general/", 'response_cache_dir' => "{$cacheDir}/response/", 'syndication_core_xsd_path' => "{$appDir}/alpha/config/syndication.core.xsd");
 }
Esempio n. 4
0
 /**
  * Initialize the plugins management
  * @param string $configFile
  * @param string $cacheNamespace
  */
 public static function init($configFile = null, $cacheNamespace = null)
 {
     // already initialized
     if (self::$configFile) {
         return;
     }
     if ($configFile) {
         self::$configFile = $configFile;
     } else {
         $configDir = kEnvironment::getConfigDir();
         self::$configFile = "{$configDir}/plugins.ini";
     }
     if ($cacheNamespace) {
         self::$cacheNamespace = $cacheNamespace;
     }
 }
Esempio n. 5
0
function getFileSyncWorkers($iniDir)
{
    $configFileName = kEnvironment::get('cache_root_path') . DIRECTORY_SEPARATOR . 'batch' . DIRECTORY_SEPARATOR . 'fileSyncStatus-config.ini';
    @mkdir(dirname($configFileName), 0777, true);
    $filePaths = getIniFilePaths($iniDir);
    implodeDirectoryFiles($filePaths, $configFileName);
    $config = new Zend_Config_Ini($configFileName);
    $batchConfig = $config->toArray();
    $result = array();
    foreach ($batchConfig as $section) {
        if (!isset($section["id"]) || !isset($section["scriptPath"]) || strpos($section["scriptPath"], 'KAsyncFileSyncImportExe') === false) {
            continue;
        }
        $result[] = array('id' => $section["id"], 'name' => $section["friendlyName"], 'filter' => $section["filter"]);
    }
    return $result;
}
Esempio n. 6
0
<?php

/**
 * 
 * @package Scheduler
 */
chdir(__DIR__);
define('KALTURA_ROOT_PATH', realpath(__DIR__ . '/../'));
require_once KALTURA_ROOT_PATH . '/alpha/config/kConf.php';
define("KALTURA_BATCH_PATH", KALTURA_ROOT_PATH . "/batch");
// Autoloader - override the autoloader defaults
require_once KALTURA_ROOT_PATH . "/infra/KAutoloader.php";
KAutoloader::setClassPath(array(KAutoloader::buildPath(KALTURA_ROOT_PATH, "infra", "*"), KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "*"), KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*"), KAutoloader::buildPath(KALTURA_BATCH_PATH, "*")));
KAutoloader::addClassPath(KAutoloader::buildPath(KALTURA_ROOT_PATH, "plugins", "*", "batch", "*"));
KAutoloader::setIncludePath(array(KAutoloader::buildPath(KALTURA_ROOT_PATH, "vendor", "ZendFramework", "library")));
KAutoloader::setClassMapFilePath(kEnvironment::get("cache_root_path") . '/batch/classMap.cache');
KAutoloader::register();
// Logger
$loggerConfigPath = KALTURA_ROOT_PATH . "/configurations/logger.ini";
try {
    $config = new Zend_Config_Ini($loggerConfigPath);
    KalturaLog::initLog($config->batch_scheduler);
    KalturaLog::setContext("BATCH");
} catch (Zend_Config_Exception $ex) {
}
Esempio n. 7
0
 protected function _loadIniFile($filename)
 {
     set_error_handler(array($this, '_loadFileErrorHandler'));
     $loaded = parse_ini_file($filename, true);
     // Warnings and errors are suppressed
     restore_error_handler();
     // Check if there was a error while loading file
     if ($this->_loadFileErrorStr !== null) {
         /**
          * @see Zend_Config_Exception
          */
         require_once 'Zend/Config/Exception.php';
         throw new Zend_Config_Exception($this->_loadFileErrorStr);
     }
     $extensions = array();
     foreach ($loaded as $extensionName => $extension) {
         if (strpos($extensionName, self::EXTENSION_SEPARATOR) > 0) {
             $extensions[$extensionName] = $extension;
             unset($loaded[$extensionName]);
         }
     }
     $iniArray = array();
     foreach ($loaded as $key => $data) {
         $pieces = explode($this->_sectionSeparator, $key);
         $thisSection = trim($pieces[0]);
         switch (count($pieces)) {
             case 1:
                 $iniArray[$thisSection] = $data;
                 break;
             case 2:
                 $extendedSection = trim($pieces[1]);
                 $iniArray[$thisSection] = array_merge(array(';extends' => $extendedSection), $data);
                 break;
             default:
                 /**
                  * @see Zend_Config_Exception
                  */
                 require_once 'Zend/Config/Exception.php';
                 throw new Zend_Config_Exception("Section '{$thisSection}' may not extend multiple sections in {$filename}");
         }
     }
     foreach ($extensions as $extensionName => $extension) {
         list($section, $extensionSufix) = explode(self::EXTENSION_SEPARATOR, $extensionName, 2);
         if (!isset($iniArray[$section])) {
             throw new Zend_Config_Exception("Section '{$section}' cannot be found in {$filename}, '{$extensionName}' is invalid extension name");
         }
         $iniArray[$section] = kEnvironment::mergeConfigItem($iniArray[$section], $extension, false, false);
     }
     return $iniArray;
 }
 /**
  * @return string
  */
 protected static function getCachePath()
 {
     $path = kEnvironment::get("cache_root_path") . DIRECTORY_SEPARATOR . 'batch';
     if (!file_exists($path)) {
         kFile::fullMkdir($path);
     }
     return $path;
 }