From 099bee2f82c8c651924d34cdb108a709f662f9a5 Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Wed, 24 Oct 2007 00:38:11 +0000 Subject: [PATCH] Merged in from DEV trunk... --- bin/taskrunner.sh | 3 +-- search2/indexing/indexerCore.inc.php | 22 +++++++++++++++++++--- sql/mysql/install/data.sql | 2 +- templates/ktcore/dashlets/scheduler.smarty | 4 +++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bin/taskrunner.sh b/bin/taskrunner.sh index c8abe6c..21d42ca 100644 --- a/bin/taskrunner.sh +++ b/bin/taskrunner.sh @@ -1,3 +1,2 @@ #!/bin/sh -"@@BITROCK_INSTALLDIR@@/php/bin/php" "@@BITROCK_INSTALLDIR@@/knowledgeTree/bin/taskrunner.php" - +../../php/bin/php taskrunner.php diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 6f76776..e04249c 100644 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -635,13 +635,15 @@ abstract class Indexer } $default->log->info('checkForRegisteredTypes: start'); - $this->registerTypes(true); + $date = date('Y-m-d H:i'); + $sql = "UPDATE scheduler_tasks SET run_time='$date'"; + DBUtil::runQuery($sql); + $this->registerTypes(true); $disable = array( OS_WINDOWS=>array('PSExtractor'), OS_UNIX => array() - ); foreach($disable[OS_WINDOWS] as $extractor) @@ -664,16 +666,27 @@ abstract class Indexer public function indexDocuments($max=null) { global $default; + $config =& KTConfig::getSingleton(); + + $indexLockFile = $config->get('cache/cacheDirectory') . '/main.index.lock'; + if (is_file($indexLockFile)) + { + $default->log->info('indexDocuments: main.index.lock seems to exist. it could be that the indexing is still underway.'); + $default->log->info('indexDocuments: Remove "' . $indexLockFile . '" if the indexing is not running or extend the frequency at which the background task runs!'); + return; + } + touch($indexLockFile); + $this->checkForRegisteredTypes(); $default->log->info('indexDocuments: start'); if (!$this->doesDiagnosticsPass()) { + unlink($indexLockFile); return; } - $config =& KTConfig::getSingleton(); if (is_null($max)) { $max = $config->get('indexer/batchDocuments',20); @@ -702,12 +715,14 @@ abstract class Indexer $result = DBUtil::getResultArray($sql); if (PEAR::isError($result)) { + unlink($indexLockFile); return; } // bail if no work to do if (count($result) == 0) { + unlink($indexLockFile); return; } @@ -915,6 +930,7 @@ abstract class Indexer } $default->log->info('indexDocuments: done'); + unlink($indexLockFile); } public function migrateDocuments($max=null) diff --git a/sql/mysql/install/data.sql b/sql/mysql/install/data.sql index c70e5a6..fb23184 100644 --- a/sql/mysql/install/data.sql +++ b/sql/mysql/install/data.sql @@ -794,7 +794,7 @@ UNLOCK TABLES; LOCK TABLES `scheduler_tasks` WRITE; /*!40000 ALTER TABLE `scheduler_tasks` DISABLE KEYS */; -INSERT INTO `scheduler_tasks` VALUES (1,'Indexing','/knowledgetree/ktdms.trunk/bin/indexingTask.sh','',0,'1min',NULL,NULL,0),(2,'Index Migration','/knowledgetree/ktdms.trunk/bin/indexMigrationTask.sh','',0,'5mins',NULL,NULL,0),(3,'Index Optimisation','/knowledgetree/ktdms.trunk/bin/optimizeIndexes.sh','',0,'weekly',NULL,NULL,0); +INSERT INTO `scheduler_tasks` VALUES (1,'Indexing','../bin/indexingTask.sh','',0,'1min','2007-10-01',NULL,0),(2,'Index Migration','../bin/indexMigrationTask.sh','',0,'5mins','2007-10-01',NULL,0),(3,'Index Optimisation','../bin/optimizeIndexes.sh','',0,'weekly','2007-10-01',NULL,0); /*!40000 ALTER TABLE `scheduler_tasks` ENABLE KEYS */; UNLOCK TABLES; diff --git a/templates/ktcore/dashlets/scheduler.smarty b/templates/ktcore/dashlets/scheduler.smarty index 56f3a76..f166fa9 100644 --- a/templates/ktcore/dashlets/scheduler.smarty +++ b/templates/ktcore/dashlets/scheduler.smarty @@ -8,11 +8,13 @@  Administration page

+{if !$lasttime} {if $isDue} {i18n arg_time=$timedif}The tasks were scheduled to be run #time# ago.{/i18n} {else} {i18n arg_time=$timedif}The tasks are scheduled to be run in #time#.{/i18n} {/if} +{/if}

@@ -42,7 +44,7 @@ {i18n}Please ensure that the scheduler is listed in your cron jobs. The line to be added to the crontab to implement the cron job is: {/i18n}

- +

-- libgit2 0.21.4