コード例 #1
0
ファイル: Cron.php プロジェクト: kingsj/core
 /**
  * Preprocessor for no-action
  *
  * @return void
  */
 protected function doNoAction()
 {
     $this->startTime = time();
     $this->startMemory = memory_get_usage(true);
     $this->memoryLimitIni = \XLite\Core\Converter::convertShortSize(ini_get('memory_limit') ?: '16M');
     foreach (\XLite\Core\Database::getRepo('XLite\\Model\\Task')->getCurrentQuery() as $task) {
         $task = $task[0];
         $runner = $task->getOwnerInstance();
         if ($runner) {
             $this->runRunner($runner);
         }
         sleep($this->sleepTime);
         if (!$this->checkThreadResource()) {
             $time = gmdate('H:i:s', time() - $this->startTime);
             $memory = \XLite\Core\Converter::formatFileSize(memory_get_usage(true));
             $this->printContent('Step is interrupted (time: ' . $time . '; memory usage: ' . $memory . ')');
             break;
         }
     }
 }
コード例 #2
0
ファイル: AView.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Prepare human-readable output for file size
  *
  * @param integer $size Size in bytes
  *
  * @return string
  */
 protected function formatFileSize($size)
 {
     return \XLite\Core\Converter::formatFileSize($size);
 }
コード例 #3
0
ファイル: Cell.php プロジェクト: kewaunited/xcart
 /**
  * Check if there is enough disk free space.
  * Return message on error
  *
  * @return string
  */
 protected function checkDiskFreeSpace()
 {
     $message = null;
     $totalSize = \Includes\Utils\ArrayManager::sumObjectsArrayFieldValues($this->getEntries(), 'getPackSize');
     $freeSpaceRaw = \Includes\Utils\FileManager::getDiskFreeSpace(LC_DIR_TMP);
     $freeSpace = null !== $freeSpaceRaw ? max(0, $freeSpaceRaw - self::FREE_SPACE_RESERVE) : null;
     if (null !== $freeSpace && $totalSize > $freeSpace) {
         $message = \XLite\Core\Translation::getInstance()->translate('Not enough disk space. Required: {{req}} (+{{reserve}} reserve). Available: {{avail}}', array('req' => \XLite\Core\Converter::formatFileSize($totalSize), 'reserve' => \XLite\Core\Converter::formatFileSize(self::FREE_SPACE_RESERVE), 'avail' => \XLite\Core\Converter::formatFileSize($freeSpace)));
     }
     return $message;
 }