Commit 099bee2f82c8c651924d34cdb108a709f662f9a5

Authored by kevin_fourie
1 parent 1dac1392

Merged in from DEV trunk...

KTS-2414
"Implement a dashlet for the scheduler"
Updated. When no jobs have been run, it says they were last run 1974 weeks ago... Changed this!

Committed by: Conrad Vermeulen
Reviewed by: Kevin Fourie

KTS-2414
"Implement a dashlet for the scheduler"
Updated. Updated paths of scheduled tasks.

Committed by: Conrad Vermeulen
Reviewed by: Kevin Fourie

KTS-673
"The search algorithm needs some work"
Updated. Prevent multiple instances of indexer running which may lock the server under load

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

KTS-2568
"Add scheduler service to Linux"
Updated sh file.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen

KTS-673
"The search algorithm needs some work"
Updated. Scheduler initialised when indexer is first run.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7539 c91229c3-7414-0410-bfa2-8a42b809f60b
bin/taskrunner.sh
1 #!/bin/sh 1 #!/bin/sh
2 -"@@BITROCK_INSTALLDIR@@/php/bin/php" "@@BITROCK_INSTALLDIR@@/knowledgeTree/bin/taskrunner.php"  
3 - 2 +../../php/bin/php taskrunner.php
search2/indexing/indexerCore.inc.php
@@ -635,13 +635,15 @@ abstract class Indexer @@ -635,13 +635,15 @@ abstract class Indexer
635 } 635 }
636 $default->log->info('checkForRegisteredTypes: start'); 636 $default->log->info('checkForRegisteredTypes: start');
637 637
638 - $this->registerTypes(true); 638 + $date = date('Y-m-d H:i');
  639 + $sql = "UPDATE scheduler_tasks SET run_time='$date'";
  640 + DBUtil::runQuery($sql);
639 641
  642 + $this->registerTypes(true);
640 643
641 $disable = array( 644 $disable = array(
642 OS_WINDOWS=>array('PSExtractor'), 645 OS_WINDOWS=>array('PSExtractor'),
643 OS_UNIX => array() 646 OS_UNIX => array()
644 -  
645 ); 647 );
646 648
647 foreach($disable[OS_WINDOWS] as $extractor) 649 foreach($disable[OS_WINDOWS] as $extractor)
@@ -664,16 +666,27 @@ abstract class Indexer @@ -664,16 +666,27 @@ abstract class Indexer
664 public function indexDocuments($max=null) 666 public function indexDocuments($max=null)
665 { 667 {
666 global $default; 668 global $default;
  669 + $config =& KTConfig::getSingleton();
  670 +
  671 + $indexLockFile = $config->get('cache/cacheDirectory') . '/main.index.lock';
  672 + if (is_file($indexLockFile))
  673 + {
  674 + $default->log->info('indexDocuments: main.index.lock seems to exist. it could be that the indexing is still underway.');
  675 + $default->log->info('indexDocuments: Remove "' . $indexLockFile . '" if the indexing is not running or extend the frequency at which the background task runs!');
  676 + return;
  677 + }
  678 + touch($indexLockFile);
  679 +
667 680
668 $this->checkForRegisteredTypes(); 681 $this->checkForRegisteredTypes();
669 682
670 $default->log->info('indexDocuments: start'); 683 $default->log->info('indexDocuments: start');
671 if (!$this->doesDiagnosticsPass()) 684 if (!$this->doesDiagnosticsPass())
672 { 685 {
  686 + unlink($indexLockFile);
673 return; 687 return;
674 } 688 }
675 689
676 - $config =& KTConfig::getSingleton();  
677 if (is_null($max)) 690 if (is_null($max))
678 { 691 {
679 $max = $config->get('indexer/batchDocuments',20); 692 $max = $config->get('indexer/batchDocuments',20);
@@ -702,12 +715,14 @@ abstract class Indexer @@ -702,12 +715,14 @@ abstract class Indexer
702 $result = DBUtil::getResultArray($sql); 715 $result = DBUtil::getResultArray($sql);
703 if (PEAR::isError($result)) 716 if (PEAR::isError($result))
704 { 717 {
  718 + unlink($indexLockFile);
705 return; 719 return;
706 } 720 }
707 721
708 // bail if no work to do 722 // bail if no work to do
709 if (count($result) == 0) 723 if (count($result) == 0)
710 { 724 {
  725 + unlink($indexLockFile);
711 return; 726 return;
712 } 727 }
713 728
@@ -915,6 +930,7 @@ abstract class Indexer @@ -915,6 +930,7 @@ abstract class Indexer
915 930
916 } 931 }
917 $default->log->info('indexDocuments: done'); 932 $default->log->info('indexDocuments: done');
  933 + unlink($indexLockFile);
918 } 934 }
919 935
920 public function migrateDocuments($max=null) 936 public function migrateDocuments($max=null)
sql/mysql/install/data.sql
No preview for this file type
templates/ktcore/dashlets/scheduler.smarty
@@ -8,11 +8,13 @@ @@ -8,11 +8,13 @@
8 &nbsp;<span><a href="{$sAdmin}">Administration page</a></span> 8 &nbsp;<span><a href="{$sAdmin}">Administration page</a></span>
9 9
10 <p> 10 <p>
  11 +{if !$lasttime}
11 {if $isDue} 12 {if $isDue}
12 <span class="">{i18n arg_time=$timedif}The tasks were scheduled to be run #time# ago.{/i18n}</span> 13 <span class="">{i18n arg_time=$timedif}The tasks were scheduled to be run #time# ago.{/i18n}</span>
13 {else} 14 {else}
14 <span class="">{i18n arg_time=$timedif}The tasks are scheduled to be run in #time#.{/i18n}</span> 15 <span class="">{i18n arg_time=$timedif}The tasks are scheduled to be run in #time#.{/i18n}</span>
15 {/if} 16 {/if}
  17 +{/if}
16 </p> 18 </p>
17 19
18 20
@@ -42,7 +44,7 @@ @@ -42,7 +44,7 @@
42 {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} 44 {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}
43 <ul><li>*/5 * * * * {$sPath} > /dev/null</li></ul> 45 <ul><li>*/5 * * * * {$sPath} > /dev/null</li></ul>
44 </p> 46 </p>
45 - 47 +
46 <p> 48 <p>
47 <strong><span onclick="{$onClick}"> 49 <strong><span onclick="{$onClick}">
48 <img id="scheduler_icon" src="{$sImg}"/> 50 <img id="scheduler_icon" src="{$sImg}"/>