[Rt-commit] rt branch, 4.0/lock-fulltext-indexer, updated. rt-4.0.20-2-g2742ef9

? sunnavy sunnavy at bestpractical.com
Fri May 16 11:10:21 EDT 2014


The branch, 4.0/lock-fulltext-indexer has been updated
       via  2742ef9bb5e8df89d9839a8b28ddd3413e689731 (commit)
      from  ffc51a3253f1fffe1a5ff09fac01d4548c303979 (commit)

Summary of changes:
 docs/full_text_indexing.pod | 11 +++++++++--
 sbin/rt-fulltext-indexer.in | 13 ++++++++++---
 2 files changed, 19 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 2742ef9bb5e8df89d9839a8b28ddd3413e689731
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Fri May 16 23:05:25 2014 +0800

    add --quiet option to make fulltext-indexer more convenient in cron env
    
    so we can exit processes quietly and normally.

diff --git a/docs/full_text_indexing.pod b/docs/full_text_indexing.pod
index 0952b4e..399af7d 100644
--- a/docs/full_text_indexing.pod
+++ b/docs/full_text_indexing.pod
@@ -48,8 +48,15 @@ To keep the index up-to-date, you will need to run:
 ...at regular intervals.  By default, this will only tokenize up to 100
 tickets at a time; you can adjust this upwards by passing
 C<--limit 500>.  Larger batch sizes will take longer and
-consume more memory.  Care should be taken to ensure that multiple
-instances of C<rt-fulltext-indexer> are not run at the same time.
+consume more memory.
+
+If there are multiple instances of C<rt-fulltext-indexer> running, the latter
+ones will exit abnormally(with exit code 1) with the error message
+"rt-fulltext-indexer is already running". You can discard the message and end
+those processes normally(with exit code 0) by the C<--quiet> option, which is
+useful when running the command via C<cron>:
+
+    sbin/rt-fulltext-indexer --quiet
 
 =head1 MYSQL
 
diff --git a/sbin/rt-fulltext-indexer.in b/sbin/rt-fulltext-indexer.in
index 4280296..b90d8da 100644
--- a/sbin/rt-fulltext-indexer.in
+++ b/sbin/rt-fulltext-indexer.in
@@ -84,8 +84,9 @@ use RT::Interface::CLI ();
 my %OPT = (
     help        => 0,
     debug       => 0,
+    quiet       => 0,
 );
-my @OPT_LIST = qw(help|h! debug!);
+my @OPT_LIST = qw(help|h! debug! quiet);
 
 my $db_type = RT->Config->Get('DatabaseType');
 if ( $db_type eq 'Pg' ) {
@@ -124,8 +125,14 @@ if ( $OPT{'help'} ) {
 
 use Fcntl ':flock';
 if ( !flock main::DATA, LOCK_EX | LOCK_NB ) {
-    print STDERR "$0 is already running\n";
-    exit 1;
+    if ( $OPT{quiet} ) {
+        RT::Logger->info("$0 is already running; aborting silently, as requested");
+        exit;
+    }
+    else {
+        print STDERR "$0 is already running\n";
+        exit 1;
+    }
 }
 
 my $fts_config = RT->Config->Get('FullTextSearch') || {};

-----------------------------------------------------------------------


More information about the rt-commit mailing list