/**
  * starts new process
  * @throws Exception if no crawlerprocess was started
  */
 public function startProcess()
 {
     $ttl = time() + $this->timeToLive - 1;
     $current = $this->processRepository->countNotTimeouted($ttl);
     $completePath = '(' . escapeshellcmd($this->getCrawlerCliPath()) . ' &) > /dev/null';
     if (system($completePath) === FALSE) {
         throw new Exception('could not start process!');
     } else {
         for ($i = 0; $i < 10; $i++) {
             if ($this->processRepository->countNotTimeouted($ttl) > $current) {
                 return true;
             }
             sleep(1);
         }
         throw new Exception('Something went wrong: process did not appear within 10 seconds.');
     }
 }
 /**
  * This method is used to show an overview about the active an the finished crawling processes
  *
  * @author Timo Schmidt
  * @param void
  * @return string
  */
 protected function drawProcessOverviewAction()
 {
     global $BACK_PATH;
     $this->makeCrawlerProcessableChecks();
     $crawler = $this->findCrawler();
     try {
         $this->handleProcessOverviewActions();
     } catch (Exception $e) {
         $this->addErrorMessage($e->getMessage());
     }
     $offset = intval(t3lib_div::_GP('offset'));
     $perpage = 20;
     $processRepository = new tx_crawler_domain_process_repository();
     $queueRepository = new tx_crawler_domain_queue_repository();
     $mode = $this->pObj->MOD_SETTINGS['processListMode'];
     if ($mode == 'detail') {
         $where = '';
     } elseif ($mode == 'simple') {
         $where = 'active = 1';
     }
     $allProcesses = $processRepository->findAll('ttl', 'DESC', $perpage, $offset, $where);
     $allCount = $processRepository->countAll($where);
     $listView = new tx_crawler_view_process_list();
     $listView->setPageId($this->pObj->id);
     $listView->setIconPath($BACK_PATH . '../typo3conf/ext/crawler/template/process/res/img/');
     $listView->setProcessCollection($allProcesses);
     $listView->setCliPath($this->processManager->getCrawlerCliPath());
     $listView->setIsCrawlerEnabled(!$crawler->getDisabled() && !$this->isErrorDetected);
     $listView->setTotalUnprocessedItemCount($queueRepository->countAllPendingItems());
     $listView->setAssignedUnprocessedItemCount($queueRepository->countAllAssignedPendingItems());
     $listView->setActiveProcessCount($processRepository->countActive());
     $listView->setMaxActiveProcessCount(tx_crawler_api::forceIntegerInRange($this->extensionSettings['processLimit'], 1, 99, 1));
     $listView->setMode($mode);
     $paginationView = new tx_crawler_view_pagination();
     $paginationView->setCurrentOffset($offset);
     $paginationView->setPerPage($perpage);
     $paginationView->setTotalItemCount($allCount);
     $output = $listView->render();
     if ($paginationView->getTotalPagesCount() > 1) {
         $output .= ' <br />' . $paginationView->render();
     }
     return $output;
 }
 /**
  * Get active processes count
  *
  * @param void
  * @return int
  * @author Fabrizio Branca <*****@*****.**>
  * @since 2009-09-03
  */
 public function getActiveProcessesCount()
 {
     $processRepository = new tx_crawler_domain_process_repository();
     return $processRepository->countActive();
 }