/** * CPU adapter factory return adapter depending on operating system * * @return phpRack_Adapters_Cpu_Abstract * @throws Exception If OS is not supported * @see For MacOS I think we should use system_profiler shell command. * After that we can parse it output in similar way like we do it for * Windows or Linux * @todo #17 How about Mac OS? There is no /proc directory in Mac OS */ public static function factory() { /** * @see phpRack_Adapters_Os */ require_once PHPRACK_PATH . '/Adapters/Os.php'; $os = phpRack_Adapters_Os::get(); $classFile = PHPRACK_PATH . '/Adapters/Cpu/' . ucfirst($os) . '.php'; if (!file_exists($classFile)) { throw new Exception("OS '{$os}' is not supported yet"); } eval('require_once $classFile;'); // for ZCA validation $className = 'phpRack_Adapters_Cpu_' . ucfirst($os); return new $className(); }
/** * Get env which should be passed to proc_open() * * @return array|null * @see run() */ protected function _getEnv() { /** * @see phpRack_Adapters_Os */ require_once PHPRACK_PATH . '/Adapters/Os.php'; $os = phpRack_Adapters_Os::get(); // we must modify env only on Linux, so we should return default env in other cases if ($os != phpRack_Adapters_Os::LINUX || !isset($_ENV)) { return null; } // we must remove PATH to avoid script forking problem on some servers return array_diff_key($_ENV, array('PATH' => '')); }