X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fsbin%2Frt-fulltext-indexer;h=cdcc78e157a9e2115170a8bc7040c3f84f3b3638;hb=ed1f84b4e8f626245995ecda5afcf83092c153b2;hp=8ac0e9c21d611b19a8f78c96a6aece56fc95ee34;hpb=3d0a1bb06b895c5be6e3f0517d355442a6b1e125;p=freeside.git diff --git a/rt/sbin/rt-fulltext-indexer b/rt/sbin/rt-fulltext-indexer index 8ac0e9c21..cdcc78e15 100755 --- a/rt/sbin/rt-fulltext-indexer +++ b/rt/sbin/rt-fulltext-indexer @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -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' ) { @@ -122,6 +123,18 @@ if ( $OPT{'help'} ) { ); } +use Fcntl ':flock'; +if ( !flock main::DATA, LOCK_EX | LOCK_NB ) { + 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') || {}; unless ( $fts_config->{'Enable'} ) { print STDERR <do( $query, undef, $$text, $attachment->id ) }; unless ( $status ) { if ( $dbh->err == 7 && $dbh->state eq '54000' ) { - warn "Attachment @{[$attachment->id]} cannot be indexed, as it contains too many unique words"; + warn "Attachment @{[$attachment->id]} cannot be indexed. Most probably it contains too many unique words. Error: ". $dbh->errstr; } elsif ( $dbh->err == 7 && $dbh->state eq '22021' ) { - warn "Attachment @{[$attachment->id]} cannot be indexed, as it contains invalid UTF8 bytes"; + warn "Attachment @{[$attachment->id]} cannot be indexed. Most probably it contains invalid UTF8 bytes. Error: ". $dbh->errstr; } else { die "error: ". $dbh->errstr; } @@ -463,3 +476,4 @@ Alex Vandiver Ealexmv@bestpractical.comE =cut +__DATA__