@@ -47,7 +47,7 @@ |
||
| 47 | 47 | public function execute() |
| 48 | 48 | { |
| 49 | 49 | $processManager = new \tx_crawler_domain_process_manager(); |
| 50 | - $timeout = is_int($this->timeOut) ? (int)$this->timeOut : 1800; |
|
| 50 | + $timeout = is_int($this->timeOut) ? (int) $this->timeOut : 1800; |
|
| 51 | 51 | |
| 52 | 52 | try { |
| 53 | 53 | $processManager->multiProcess($timeout); |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | if (!defined('TYPO3_cliMode')) { |
| 3 | - die('You cannot run this script directly!'); |
|
| 3 | + die('You cannot run this script directly!'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | $processManager = new tx_crawler_domain_process_manager(); |
| 7 | 7 | $timeout = isset($_SERVER['argv'][1] ) ? intval($_SERVER['argv'][1]) : 1800; |
| 8 | 8 | |
| 9 | 9 | try { |
| 10 | - $processManager->multiProcess($timeout); |
|
| 10 | + $processManager->multiProcess($timeout); |
|
| 11 | 11 | } catch (Exception $e) { |
| 12 | - echo PHP_EOL . $e->getMessage(); |
|
| 12 | + echo PHP_EOL . $e->getMessage(); |
|
| 13 | 13 | } |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | $processManager = new tx_crawler_domain_process_manager(); |
| 7 | -$timeout = isset($_SERVER['argv'][1] ) ? intval($_SERVER['argv'][1]) : 1800; |
|
| 7 | +$timeout = isset($_SERVER['argv'][1]) ? intval($_SERVER['argv'][1]) : 1800; |
|
| 8 | 8 | |
| 9 | 9 | try { |
| 10 | 10 | $processManager->multiProcess($timeout); |
| 11 | 11 | } catch (Exception $e) { |
| 12 | - echo PHP_EOL . $e->getMessage(); |
|
| 12 | + echo PHP_EOL.$e->getMessage(); |
|
| 13 | 13 | } |
@@ -27,175 +27,175 @@ |
||
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | 29 | class tx_crawler_domain_process_manager { |
| 30 | - /** |
|
| 31 | - * @var $timeToLive integer |
|
| 32 | - */ |
|
| 33 | - private $timeToLive; |
|
| 34 | - /** |
|
| 35 | - * @var integer |
|
| 36 | - */ |
|
| 37 | - private $countInARun; |
|
| 30 | + /** |
|
| 31 | + * @var $timeToLive integer |
|
| 32 | + */ |
|
| 33 | + private $timeToLive; |
|
| 34 | + /** |
|
| 35 | + * @var integer |
|
| 36 | + */ |
|
| 37 | + private $countInARun; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var integer |
|
| 41 | - */ |
|
| 42 | - private $processLimit; |
|
| 39 | + /** |
|
| 40 | + * @var integer |
|
| 41 | + */ |
|
| 42 | + private $processLimit; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var $crawlerObj tx_crawler_lib |
|
| 46 | - */ |
|
| 47 | - private $crawlerObj; |
|
| 44 | + /** |
|
| 45 | + * @var $crawlerObj tx_crawler_lib |
|
| 46 | + */ |
|
| 47 | + private $crawlerObj; |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * @var $queueRepository tx_crawler_domain_queue_repository |
|
| 51 | - */ |
|
| 52 | - private $queueRepository; |
|
| 49 | + /** |
|
| 50 | + * @var $queueRepository tx_crawler_domain_queue_repository |
|
| 51 | + */ |
|
| 52 | + private $queueRepository; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var tx_crawler_domain_process_repository |
|
| 56 | - */ |
|
| 57 | - private $processRepository; |
|
| 54 | + /** |
|
| 55 | + * @var tx_crawler_domain_process_repository |
|
| 56 | + */ |
|
| 57 | + private $processRepository; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @var $verbose boolean |
|
| 61 | - */ |
|
| 62 | - private $verbose; |
|
| 59 | + /** |
|
| 60 | + * @var $verbose boolean |
|
| 61 | + */ |
|
| 62 | + private $verbose; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * the constructor |
|
| 66 | - */ |
|
| 67 | - public function __construct() { |
|
| 68 | - $this->processRepository = new tx_crawler_domain_process_repository(); |
|
| 69 | - $this->queueRepository = new tx_crawler_domain_queue_repository(); |
|
| 70 | - $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
| 71 | - $this->timeToLive = intval($this->crawlerObj->extensionSettings['processMaxRunTime']); |
|
| 72 | - $this->countInARun = intval($this->crawlerObj->extensionSettings['countInARun']); |
|
| 73 | - $this->processLimit = intval($this->crawlerObj->extensionSettings['processLimit']); |
|
| 74 | - $this->verbose = intval($this->crawlerObj->extensionSettings['processVerbose']); |
|
| 75 | - } |
|
| 64 | + /** |
|
| 65 | + * the constructor |
|
| 66 | + */ |
|
| 67 | + public function __construct() { |
|
| 68 | + $this->processRepository = new tx_crawler_domain_process_repository(); |
|
| 69 | + $this->queueRepository = new tx_crawler_domain_queue_repository(); |
|
| 70 | + $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
| 71 | + $this->timeToLive = intval($this->crawlerObj->extensionSettings['processMaxRunTime']); |
|
| 72 | + $this->countInARun = intval($this->crawlerObj->extensionSettings['countInARun']); |
|
| 73 | + $this->processLimit = intval($this->crawlerObj->extensionSettings['processLimit']); |
|
| 74 | + $this->verbose = intval($this->crawlerObj->extensionSettings['processVerbose']); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * starts multiple processes |
|
| 79 | - * |
|
| 80 | - * @param integer $timeout |
|
| 81 | - */ |
|
| 82 | - public function multiProcess($timeout) { |
|
| 83 | - if ($this->processLimit <= 1) { |
|
| 84 | - throw new RuntimeException('To run crawler in multi process mode you have to configure the processLimit > 1.' . PHP_EOL); |
|
| 85 | - } |
|
| 77 | + /** |
|
| 78 | + * starts multiple processes |
|
| 79 | + * |
|
| 80 | + * @param integer $timeout |
|
| 81 | + */ |
|
| 82 | + public function multiProcess($timeout) { |
|
| 83 | + if ($this->processLimit <= 1) { |
|
| 84 | + throw new RuntimeException('To run crawler in multi process mode you have to configure the processLimit > 1.' . PHP_EOL); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $pendingItemsStart = $this->queueRepository->countAllPendingItems(); |
|
| 88 | - $itemReportLimit = 20; |
|
| 89 | - $reportItemCount = $pendingItemsStart - $itemReportLimit; |
|
| 90 | - if ($this->verbose) { |
|
| 91 | - $this->reportItemStatus(); |
|
| 92 | - } |
|
| 93 | - $this->startRequiredProcesses(); |
|
| 94 | - $nextTimeOut = time() + $this->timeToLive; |
|
| 95 | - for ($i = 0; $i < $timeout; $i++) { |
|
| 96 | - $currentPendingItems = $this->queueRepository->countAllPendingItems(); |
|
| 97 | - if ($this->startRequiredProcesses($this->verbose)) { |
|
| 98 | - $nextTimeOut = time() + $this->timeToLive; |
|
| 99 | - } |
|
| 100 | - if ($currentPendingItems == 0) { |
|
| 101 | - if ($this->verbose) { |
|
| 102 | - echo 'Finished...' . chr(10); |
|
| 103 | - } |
|
| 104 | - break; |
|
| 105 | - } |
|
| 106 | - if ($currentPendingItems < $reportItemCount) { |
|
| 107 | - if ($this->verbose) { |
|
| 108 | - $this->reportItemStatus(); |
|
| 109 | - } |
|
| 110 | - $reportItemCount = $currentPendingItems - $itemReportLimit; |
|
| 111 | - } |
|
| 112 | - sleep(1); |
|
| 113 | - if ($nextTimeOut < time()) { |
|
| 114 | - $timedOutProcesses = $this->processRepository->findAll('', 'DESC', NULL, 0, 'ttl >' . $nextTimeOut); |
|
| 115 | - $nextTimeOut = time() + $this->timeToLive; |
|
| 116 | - if ($this->verbose) { |
|
| 117 | - echo 'Cleanup' . implode(',', $timedOutProcesses->getProcessIds()) . chr(10); |
|
| 118 | - } |
|
| 119 | - $this->crawlerObj->CLI_releaseProcesses($timedOutProcesses->getProcessIds(), true); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - if ($currentPendingItems > 0 && $this->verbose) { |
|
| 123 | - echo 'Stop with timeout' . chr(10); |
|
| 124 | - } |
|
| 125 | - } |
|
| 87 | + $pendingItemsStart = $this->queueRepository->countAllPendingItems(); |
|
| 88 | + $itemReportLimit = 20; |
|
| 89 | + $reportItemCount = $pendingItemsStart - $itemReportLimit; |
|
| 90 | + if ($this->verbose) { |
|
| 91 | + $this->reportItemStatus(); |
|
| 92 | + } |
|
| 93 | + $this->startRequiredProcesses(); |
|
| 94 | + $nextTimeOut = time() + $this->timeToLive; |
|
| 95 | + for ($i = 0; $i < $timeout; $i++) { |
|
| 96 | + $currentPendingItems = $this->queueRepository->countAllPendingItems(); |
|
| 97 | + if ($this->startRequiredProcesses($this->verbose)) { |
|
| 98 | + $nextTimeOut = time() + $this->timeToLive; |
|
| 99 | + } |
|
| 100 | + if ($currentPendingItems == 0) { |
|
| 101 | + if ($this->verbose) { |
|
| 102 | + echo 'Finished...' . chr(10); |
|
| 103 | + } |
|
| 104 | + break; |
|
| 105 | + } |
|
| 106 | + if ($currentPendingItems < $reportItemCount) { |
|
| 107 | + if ($this->verbose) { |
|
| 108 | + $this->reportItemStatus(); |
|
| 109 | + } |
|
| 110 | + $reportItemCount = $currentPendingItems - $itemReportLimit; |
|
| 111 | + } |
|
| 112 | + sleep(1); |
|
| 113 | + if ($nextTimeOut < time()) { |
|
| 114 | + $timedOutProcesses = $this->processRepository->findAll('', 'DESC', NULL, 0, 'ttl >' . $nextTimeOut); |
|
| 115 | + $nextTimeOut = time() + $this->timeToLive; |
|
| 116 | + if ($this->verbose) { |
|
| 117 | + echo 'Cleanup' . implode(',', $timedOutProcesses->getProcessIds()) . chr(10); |
|
| 118 | + } |
|
| 119 | + $this->crawlerObj->CLI_releaseProcesses($timedOutProcesses->getProcessIds(), true); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + if ($currentPendingItems > 0 && $this->verbose) { |
|
| 123 | + echo 'Stop with timeout' . chr(10); |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Reports curent Status of queue |
|
| 129 | - */ |
|
| 130 | - protected function reportItemStatus() { |
|
| 131 | - echo 'Pending:'.$this->queueRepository->countAllPendingItems().' / Assigned:'.$this->queueRepository->countAllAssignedPendingItems().chr(10); |
|
| 132 | - } |
|
| 127 | + /** |
|
| 128 | + * Reports curent Status of queue |
|
| 129 | + */ |
|
| 130 | + protected function reportItemStatus() { |
|
| 131 | + echo 'Pending:'.$this->queueRepository->countAllPendingItems().' / Assigned:'.$this->queueRepository->countAllAssignedPendingItems().chr(10); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * according to the given count of pending items and the countInARun Setting this method |
|
| 136 | - * starts more crawling processes |
|
| 137 | - * @return boolean if processes are started |
|
| 138 | - */ |
|
| 139 | - private function startRequiredProcesses() { |
|
| 140 | - $ret = FALSE; |
|
| 141 | - $currentProcesses= $this->processRepository->countActive(); |
|
| 142 | - $availableProcessesCount = $this->processLimit-$currentProcesses; |
|
| 143 | - $requiredProcessesCount = ceil($this->queueRepository->countAllUnassignedPendingItems() / $this->countInARun); |
|
| 144 | - $startProcessCount = min(array($availableProcessesCount,$requiredProcessesCount)); |
|
| 145 | - if ($startProcessCount <= 0) { |
|
| 146 | - return $ret; |
|
| 147 | - } |
|
| 148 | - if ($startProcessCount && $this->verbose) { |
|
| 149 | - echo 'Start '.$startProcessCount.' new processes (Running:'.$currentProcesses.')'; |
|
| 150 | - } |
|
| 151 | - for($i=0;$i<$startProcessCount;$i++) { |
|
| 152 | - usleep(100); |
|
| 153 | - if ($this->startProcess()) { |
|
| 154 | - if ($this->verbose) { |
|
| 155 | - echo '.'; |
|
| 156 | - $ret = TRUE; |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - if ($this->verbose) { |
|
| 161 | - echo chr(10); |
|
| 162 | - } |
|
| 163 | - return $ret; |
|
| 164 | - } |
|
| 134 | + /** |
|
| 135 | + * according to the given count of pending items and the countInARun Setting this method |
|
| 136 | + * starts more crawling processes |
|
| 137 | + * @return boolean if processes are started |
|
| 138 | + */ |
|
| 139 | + private function startRequiredProcesses() { |
|
| 140 | + $ret = FALSE; |
|
| 141 | + $currentProcesses= $this->processRepository->countActive(); |
|
| 142 | + $availableProcessesCount = $this->processLimit-$currentProcesses; |
|
| 143 | + $requiredProcessesCount = ceil($this->queueRepository->countAllUnassignedPendingItems() / $this->countInARun); |
|
| 144 | + $startProcessCount = min(array($availableProcessesCount,$requiredProcessesCount)); |
|
| 145 | + if ($startProcessCount <= 0) { |
|
| 146 | + return $ret; |
|
| 147 | + } |
|
| 148 | + if ($startProcessCount && $this->verbose) { |
|
| 149 | + echo 'Start '.$startProcessCount.' new processes (Running:'.$currentProcesses.')'; |
|
| 150 | + } |
|
| 151 | + for($i=0;$i<$startProcessCount;$i++) { |
|
| 152 | + usleep(100); |
|
| 153 | + if ($this->startProcess()) { |
|
| 154 | + if ($this->verbose) { |
|
| 155 | + echo '.'; |
|
| 156 | + $ret = TRUE; |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + if ($this->verbose) { |
|
| 161 | + echo chr(10); |
|
| 162 | + } |
|
| 163 | + return $ret; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * starts new process |
|
| 168 | - * @throws Exception if no crawlerprocess was started |
|
| 169 | - */ |
|
| 170 | - public function startProcess() { |
|
| 171 | - $ttl = (time() + $this->timeToLive -1); |
|
| 172 | - $current = $this->processRepository->countNotTimeouted($ttl); |
|
| 173 | - $completePath = '(' .escapeshellcmd($this->getCrawlerCliPath()) . ' &) > /dev/null'; |
|
| 174 | - if (system($completePath) === FALSE) { |
|
| 175 | - throw new Exception('could not start process!'); |
|
| 176 | - } |
|
| 177 | - else { |
|
| 178 | - for ($i=0;$i<10;$i++) { |
|
| 179 | - if ($this->processRepository->countNotTimeouted($ttl) > $current) { |
|
| 180 | - return true; |
|
| 181 | - } |
|
| 182 | - sleep(1); |
|
| 183 | - } |
|
| 184 | - throw new Exception('Something went wrong: process did not appear within 10 seconds.'); |
|
| 185 | - } |
|
| 186 | - } |
|
| 166 | + /** |
|
| 167 | + * starts new process |
|
| 168 | + * @throws Exception if no crawlerprocess was started |
|
| 169 | + */ |
|
| 170 | + public function startProcess() { |
|
| 171 | + $ttl = (time() + $this->timeToLive -1); |
|
| 172 | + $current = $this->processRepository->countNotTimeouted($ttl); |
|
| 173 | + $completePath = '(' .escapeshellcmd($this->getCrawlerCliPath()) . ' &) > /dev/null'; |
|
| 174 | + if (system($completePath) === FALSE) { |
|
| 175 | + throw new Exception('could not start process!'); |
|
| 176 | + } |
|
| 177 | + else { |
|
| 178 | + for ($i=0;$i<10;$i++) { |
|
| 179 | + if ($this->processRepository->countNotTimeouted($ttl) > $current) { |
|
| 180 | + return true; |
|
| 181 | + } |
|
| 182 | + sleep(1); |
|
| 183 | + } |
|
| 184 | + throw new Exception('Something went wrong: process did not appear within 10 seconds.'); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - /** |
|
| 189 | - * Returns the path to start the crawler from the command line |
|
| 190 | - * |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 193 | - public function getCrawlerCliPath(){ |
|
| 194 | - $phpPath = $this->crawlerObj->extensionSettings['phpPath'] . ' '; |
|
| 195 | - $pathToTypo3 = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '/'); |
|
| 196 | - $pathToTypo3 .= rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/'); |
|
| 197 | - $cliPart = '/typo3/cli_dispatch.phpsh crawler'; |
|
| 198 | - return $phpPath.$pathToTypo3.$cliPart; |
|
| 199 | - } |
|
| 188 | + /** |
|
| 189 | + * Returns the path to start the crawler from the command line |
|
| 190 | + * |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | + public function getCrawlerCliPath(){ |
|
| 194 | + $phpPath = $this->crawlerObj->extensionSettings['phpPath'] . ' '; |
|
| 195 | + $pathToTypo3 = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '/'); |
|
| 196 | + $pathToTypo3 .= rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/'); |
|
| 197 | + $cliPart = '/typo3/cli_dispatch.phpsh crawler'; |
|
| 198 | + return $phpPath.$pathToTypo3.$cliPart; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | 201 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * Manages cralwer processes and can be used to start a new process or multiple processes |
| 27 | 27 | * |
| 28 | 28 | */ |
| 29 | -class tx_crawler_domain_process_manager { |
|
| 29 | +class tx_crawler_domain_process_manager { |
|
| 30 | 30 | /** |
| 31 | 31 | * @var $timeToLive integer |
| 32 | 32 | */ |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * the constructor |
| 66 | 66 | */ |
| 67 | 67 | public function __construct() { |
| 68 | - $this->processRepository = new tx_crawler_domain_process_repository(); |
|
| 69 | - $this->queueRepository = new tx_crawler_domain_queue_repository(); |
|
| 68 | + $this->processRepository = new tx_crawler_domain_process_repository(); |
|
| 69 | + $this->queueRepository = new tx_crawler_domain_queue_repository(); |
|
| 70 | 70 | $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
| 71 | 71 | $this->timeToLive = intval($this->crawlerObj->extensionSettings['processMaxRunTime']); |
| 72 | 72 | $this->countInARun = intval($this->crawlerObj->extensionSettings['countInARun']); |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function multiProcess($timeout) { |
| 83 | 83 | if ($this->processLimit <= 1) { |
| 84 | - throw new RuntimeException('To run crawler in multi process mode you have to configure the processLimit > 1.' . PHP_EOL); |
|
| 84 | + throw new RuntimeException('To run crawler in multi process mode you have to configure the processLimit > 1.'.PHP_EOL); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $pendingItemsStart = $this->queueRepository->countAllPendingItems(); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | if ($currentPendingItems == 0) { |
| 101 | 101 | if ($this->verbose) { |
| 102 | - echo 'Finished...' . chr(10); |
|
| 102 | + echo 'Finished...'.chr(10); |
|
| 103 | 103 | } |
| 104 | 104 | break; |
| 105 | 105 | } |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | sleep(1); |
| 113 | 113 | if ($nextTimeOut < time()) { |
| 114 | - $timedOutProcesses = $this->processRepository->findAll('', 'DESC', NULL, 0, 'ttl >' . $nextTimeOut); |
|
| 114 | + $timedOutProcesses = $this->processRepository->findAll('', 'DESC', NULL, 0, 'ttl >'.$nextTimeOut); |
|
| 115 | 115 | $nextTimeOut = time() + $this->timeToLive; |
| 116 | 116 | if ($this->verbose) { |
| 117 | - echo 'Cleanup' . implode(',', $timedOutProcesses->getProcessIds()) . chr(10); |
|
| 117 | + echo 'Cleanup'.implode(',', $timedOutProcesses->getProcessIds()).chr(10); |
|
| 118 | 118 | } |
| 119 | 119 | $this->crawlerObj->CLI_releaseProcesses($timedOutProcesses->getProcessIds(), true); |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | if ($currentPendingItems > 0 && $this->verbose) { |
| 123 | - echo 'Stop with timeout' . chr(10); |
|
| 123 | + echo 'Stop with timeout'.chr(10); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -138,17 +138,17 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | private function startRequiredProcesses() { |
| 140 | 140 | $ret = FALSE; |
| 141 | - $currentProcesses= $this->processRepository->countActive(); |
|
| 142 | - $availableProcessesCount = $this->processLimit-$currentProcesses; |
|
| 141 | + $currentProcesses = $this->processRepository->countActive(); |
|
| 142 | + $availableProcessesCount = $this->processLimit - $currentProcesses; |
|
| 143 | 143 | $requiredProcessesCount = ceil($this->queueRepository->countAllUnassignedPendingItems() / $this->countInARun); |
| 144 | - $startProcessCount = min(array($availableProcessesCount,$requiredProcessesCount)); |
|
| 144 | + $startProcessCount = min(array($availableProcessesCount, $requiredProcessesCount)); |
|
| 145 | 145 | if ($startProcessCount <= 0) { |
| 146 | 146 | return $ret; |
| 147 | 147 | } |
| 148 | 148 | if ($startProcessCount && $this->verbose) { |
| 149 | 149 | echo 'Start '.$startProcessCount.' new processes (Running:'.$currentProcesses.')'; |
| 150 | 150 | } |
| 151 | - for($i=0;$i<$startProcessCount;$i++) { |
|
| 151 | + for ($i = 0; $i < $startProcessCount; $i++) { |
|
| 152 | 152 | usleep(100); |
| 153 | 153 | if ($this->startProcess()) { |
| 154 | 154 | if ($this->verbose) { |
@@ -168,14 +168,14 @@ discard block |
||
| 168 | 168 | * @throws Exception if no crawlerprocess was started |
| 169 | 169 | */ |
| 170 | 170 | public function startProcess() { |
| 171 | - $ttl = (time() + $this->timeToLive -1); |
|
| 171 | + $ttl = (time() + $this->timeToLive - 1); |
|
| 172 | 172 | $current = $this->processRepository->countNotTimeouted($ttl); |
| 173 | - $completePath = '(' .escapeshellcmd($this->getCrawlerCliPath()) . ' &) > /dev/null'; |
|
| 173 | + $completePath = '('.escapeshellcmd($this->getCrawlerCliPath()).' &) > /dev/null'; |
|
| 174 | 174 | if (system($completePath) === FALSE) { |
| 175 | 175 | throw new Exception('could not start process!'); |
| 176 | 176 | } |
| 177 | 177 | else { |
| 178 | - for ($i=0;$i<10;$i++) { |
|
| 178 | + for ($i = 0; $i < 10; $i++) { |
|
| 179 | 179 | if ($this->processRepository->countNotTimeouted($ttl) > $current) { |
| 180 | 180 | return true; |
| 181 | 181 | } |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | - public function getCrawlerCliPath(){ |
|
| 194 | - $phpPath = $this->crawlerObj->extensionSettings['phpPath'] . ' '; |
|
| 195 | - $pathToTypo3 = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '/'); |
|
| 196 | - $pathToTypo3 .= rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/'); |
|
| 193 | + public function getCrawlerCliPath() { |
|
| 194 | + $phpPath = $this->crawlerObj->extensionSettings['phpPath'].' '; |
|
| 195 | + $pathToTypo3 = rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_DOCUMENT_ROOT'), '/'); |
|
| 196 | + $pathToTypo3 .= rtrim(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'), '/'); |
|
| 197 | 197 | $cliPart = '/typo3/cli_dispatch.phpsh crawler'; |
| 198 | 198 | return $phpPath.$pathToTypo3.$cliPart; |
| 199 | 199 | } |