/** * 运行守护进程,归档日志文件。 * * @see ZtChart_Model_Monitor_Abstract::run() */ public function run() { sleep($this->_console->getDelayTimestamp()); while (true) { $this->_timestamp = $timestamp = time(); $deadlineTimestamp = $timestamp - self::CYCLE_TIMESTAMP; $this->import($this->_console->getLogPaths(), $deadlineTimestamp); $storage = new ZtChart_Model_Storage('monitor', 'archive'); $storage->write($deadlineTimestamp); time_sleep_until($timestamp + self::CYCLE_TIMESTAMP); } }
/** * 运行守护进程,归档日志文件。 * * @see ZtChart_Model_Monitor_Abstract::run() */ public function run() { if (!is_numeric($startTimestamp = $this->_console->getStartTimestamp())) { if (false === ($startTimestamp = strtotime($startTimestamp))) { throw new ZtChart_Model_Monitor_Daemon_Exception('Start datetime format error.'); } } $this->_timestamp = $startTimestamp; while (true) { if (date($this->_pattern) == date($this->_pattern, $this->_timestamp) || date($this->_pattern, $this->_console->getEndTimestamp()) == date($this->_pattern, $this->_timestamp)) { break; } $this->import($this->_console->getLogPaths(), $this->_timestamp); $storage = new ZtChart_Model_Storage('monitor', 'backup'); $storage->write($this->_timestamp); $this->_timestamp += self::CYCLE_TIMESTAMP; } }