diff --git a/search2/documentProcessor/documentProcessor.inc.php b/search2/documentProcessor/documentProcessor.inc.php index 65a72f3..f048840 100644 --- a/search2/documentProcessor/documentProcessor.inc.php +++ b/search2/documentProcessor/documentProcessor.inc.php @@ -144,6 +144,16 @@ class DocumentProcessor global $default; $default->log->debug('documentProcessor: starting'); + // Check for lock file to ensure processor is not currently running + $cacheDir = $default->cacheDirectory; + $lockFile = $cacheDir . DIRECTORY_SEPARATOR . 'document_processor.lock'; + + if(file_exists($lockFile)){ + // lock file exists, exit + $default->log->debug('documentProcessor: stopping, lock file in place '.$lockFile); + return ; + } + if($default->enableIndexing){ // Setup indexing - load extractors, run diagnostics if($this->indexer->preIndexingSetup() === false){ @@ -160,6 +170,10 @@ class DocumentProcessor return ; } + // indexing starting - create lock file + touch($lockFile); + + // Process queue foreach($queue as $item){ @@ -198,6 +212,11 @@ class DocumentProcessor // update the indexer statistics $this->indexer->updateIndexStats(); + // Remove lock file to indicate processing has completed + if(file_exists($lockFile)){ + @unlink($lockFile); + } + $default->log->debug('documentProcessor: stopping'); }