public static function mergeArgs($args) { foreach ($args as $alias => $value) { if ($path = self::get("Aliases.{$alias}.path")) { Helper::array_set(static::$data, $path, $value); } } }
public function __construct(array $config) { $this->type = Helper::array_get($config, 'type', self::TYPE_UNIX); if ($this->type == self::TYPE_UNIX) { $this->file = Helper::array_get($config, 'file'); } elseif ($this->type == self::TYPE_INET) { $this->ip = Helper::array_get($config, 'ip'); $this->port = Helper::array_get($config, 'port'); if (empty($this->ip) || empty($this->port)) { throw new \Exception("Both host and port must be set"); } } }
public static function logCpu($prefix = '') { self::log('[CPU] ' . $prefix . " CPU usage: " . Helper::getCpuUsage() . "%", Logger::L_DEBUG); }
/** * разбираемся с 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); }