public static function load($config_file = null, $config_data = null) { if (!empty($config_file) && Helper::checkFile($config_file) && !($yaml = file_get_contents($config_file))) { throw new \Exception("Failed to read config file {$config_file}"); } if (empty($config_data) && !($data = Yaml::parse($yaml))) { throw new \Exception("Failed to parse config file {$config_file}"); } static::$data = static::$base = array_merge(static::$data, $data); self::$cache = array(); }
/** * разбираемся с pid-файлом */ public static function getPid() { try { Helper::checkFile(static::$pidfile, true); if (!file_exists(static::$pidfile) && !touch(static::$pidfile)) { throw new \Exception("Failed to create file '" . static::$pidfile . "'"); } } catch (\Exception $e) { static::throwException(sprintf("Failed to create or find pid-file: %s", $e->getMessage()), Logger::L_FATAL); } static::$pid = (int) file_get_contents(static::$pidfile); }