greenstone.org greenstone wiki greenstone trac planet greenstone

Changeset 16192

Show
Ignore:
Timestamp:
2008-06-25 20:01:23 (5 months ago)
Author:
osborn
Message:

Cron scheduler with further updates and fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gsdl/trunk/bin/script/schedule.pl

    r16137 r16192  
    5858use parse3; 
    5959use gsprintf 'gsprintf'; 
    60  
     60if($ENV{'GSDLOS'} eq "windows") { 
     61        eval("require \"Win32.pm\" ");  
     62
    6163 
    6264my $frequency_list =  
     
    217219    my $hashParsingResult = {};  
    218220    my $intArgLeftAfterParsing;  
    219     if($gli && $os eq "linux") {   
     221    if($gli && ($os eq "linux" || $os eq "darwin")) {   
    220222        $intArgLeftAfterParsing = parse3::parse(\@ARGV, $arguments, $hashParsingResult, "allow_extra_options");  
    221223    } else { 
     
    276278 
    277279    $newpl = "cron.pl";  
    278     my $logfile = "cron".time().".txt";   
    279280 
    280281    if($action eq "delete") { 
     
    300301        if ($os =~ /^linux$/ || $os =~ /^darwin$/) { 
    301302  
    302             $import = $import." 2>$gsdl/collect/$colname/log/$logfile"; 
    303             $build = $build." 2>>$gsdl/collect/$colname/log/$logfile";  
    304             $erase = "\\\\rm -r $gsdl/collect/$colname/index 2>>$gsdl/collect/$colname/log/$logfile"; 
    305             $erase2 = "mkdir $gsdl/collect/$colname/index 2>>$gsdl/collect/$colname/log/$logfile";   
    306             $copy = "mv $gsdl/collect/$colname/building/* $gsdl/collect/$colname/index/ 2>>$gsdl/collect/$colname/log/$logfile"; 
     303            $import = $import." 2>$gsdl/collect/$colname/log/\$logfile"; 
     304            $build = $build." 2>>$gsdl/collect/$colname/log/\$logfile";  
     305            $erase = "\\\\rm -r $gsdl/collect/$colname/index 2>>$gsdl/collect/$colname/log/\$logfile"; 
     306            $erase2 = "mkdir $gsdl/collect/$colname/index 2>>$gsdl/collect/$colname/log/\$logfile";   
     307            $copy = "mv $gsdl/collect/$colname/building/* $gsdl/collect/$colname/index/ 2>>$gsdl/collect/$colname/log/\$logfile"; 
    307308            if($email) { 
    308309                #first,we need to add backslashes before the 'at' symbol.  
     
    310311                $fromaddr =~ s/\@/\\\@/g;  
    311312 
    312                 $ecmd = "$gsdl/bin/script/sendmail.pl -to $toaddr -from $fromaddr -smtp $smtp -msgfile $gsdl/collect/$colname/log/$logfile -subject \\\"Results of build for collection $colname\\\" 2>>$gsdl/collect/$colname/log/$logfile >>$gsdl/collect/$colname/log/$logfile";  
    313  
    314                 $ecmd2 = "$gsdl/bin/script/sendmail.pl -to $toaddr -from $fromaddr -smtp $smtp -msgfile $gsdl/etc/cronlock.txt -subject \\\"Results of build for collection $colname\\\" 2>>$gsdl/collect/$colname/log/$logfile >>$gsdl/collect/$colname/log/$logfile";               
     313                $ecmd = "$gsdl/bin/script/sendmail.pl -to $toaddr -from $fromaddr -smtp $smtp -msgfile $gsdl/collect/$colname/log/\$logfile -subject \\\"Results of build for collection $colname\\\" 2>>$gsdl/collect/$colname/log/\$logfile";  
     314 
     315                $ecmd2 = "$gsdl/bin/script/sendmail.pl -to $toaddr -from $fromaddr -smtp $smtp -msgfile $gsdl/etc/cronlock.txt -subject \\\"Results of build for collection $colname\\\" 2>>$gsdl/collect/$colname/log/\$logfile";            
    315316            } 
    316317    
     
    338339            $build =~ s/\\collect/\\collect\\\"/;  
    339340 
    340             $import = "$import 2>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";  
    341             $build = "$build 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";  
    342  
    343  
    344             $erase = "rd \\\/S \\\/Q \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\" 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";  
    345             $erase2 = "md \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\" 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";  
    346             $copy = "xcopy \\\/E \\\/Y \\\"$gsdl\\\\collect\\\\$colname\\\\building\\\\*\\\" \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\\\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" "; 
     341            $import = "$import 2>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";  
     342            $build = "$build 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";  
     343 
     344 
     345            $erase = "rd \\\/S \\\/Q \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\" 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";  
     346            $erase2 = "md \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\" 2>>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";  
     347            $copy = "xcopy \\\/E \\\/Y \\\"$gsdl\\\\collect\\\\$colname\\\\building\\\\*\\\" \\\"$gsdl\\\\collect\\\\$colname\\\\index\\\\\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" "; 
    347348            if($email) { 
    348349                $toaddr =~ s/\@/\\\@/g;  
    349350                $fromaddr =~ s/\@/\\\@/g;  
    350                 $ecmd = "\\\"$gsdl\\\\bin\\\\windows\\\\perl\\\\bin\\\\perl.exe\\\" -S \\\"$gsdl\\\\bin\\\\script\\\\sendmail.pl\\\" -to $toaddr -from $fromaddr -smtp $smtp -msgfile \\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" -subject \\\"Results of build for collection $colname\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";  
    351  
    352                 $ecmd2 = "\\\"$gsdl\\\\bin\\\\windows\\\\perl\\\\bin\\\\perl.exe\\\" -S \\\"$gsdl\\\\bin\\\\script\\\\sendmail.pl\\\" -to $toaddr -from $fromaddr -smtp $smtp -msgfile \\\"$gsdl\\\\etc\\\\cronlock.txt\\\" -subject \\\"Results of build for collection $colname\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\$logfile\\\" ";            
     351                $ecmd = "\\\"$gsdl\\\\bin\\\\windows\\\\perl\\\\bin\\\\perl.exe\\\" -S \\\"$gsdl\\\\bin\\\\script\\\\sendmail.pl\\\" -to $toaddr -from $fromaddr -smtp $smtp -msgfile \\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" -subject \\\"Results of build for collection $colname\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";  
     352 
     353                $ecmd2 = "\\\"$gsdl\\\\bin\\\\windows\\\\perl\\\\bin\\\\perl.exe\\\" -S \\\"$gsdl\\\\bin\\\\script\\\\sendmail.pl\\\" -to $toaddr -from $fromaddr -smtp $smtp -msgfile \\\"$gsdl\\\\etc\\\\cronlock.txt\\\" -subject \\\"Results of build for collection $colname\\\" >>\\\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\\\" ";           
    353354            } 
    354355        } 
     
    372373        print $nf "\$ENV{'PATH'}=\"$path\"\;\n";   
    373374 
     375        print $nf "\$logfile = \"cron\".time\(\).\".txt\"\;\n"; 
     376 
    374377        if($os =~ /^windows$/) { 
    375378                print $nf "if\(-e \\\"$gsdl\\\\collect\\\\$colname\\\\etc\\\\cron.lck\\\" \"\)\{ \n";  
     
    381384        } 
    382385        else {  
    383             print $nf "    system(\"more \"$gsdl/etc/cronlock.txt\" >\"$gsdl/collect/$colname/log/$logfile\"\"\)\;\n";  
     386            if($os eq "windows") {  
     387                print $nf "    system(\"more \"$gsdl\\\\etc\\\\cronlock.txt\" >\"$gsdl\\\\collect\\\\$colname\\\\log\\\\\$logfile\"\"\)\;\n"; 
     388            } else { 
     389                print $nf "    system(\"more $gsdl/etc/cronlock/txt > $gsdl/collect/$colname/log/\$logfile \"\)\;\n";  
     390            } 
    384391 
    385392        } 
     
    396403                print $nf "system(\"echo lock \>\\\"$gsdl\\\\collect\\\\$colname\\\\etc\\\\cron.lck\\\"\")\;\n";  
    397404        } else {  
    398                 print $nf "system(\"echo lock >\\\"$gsdl/collect/$colname/etc/cron.lck\\\" \")\;\n";  
     405                print $nf "system(\"echo lock >$gsdl/collect/$colname/etc/cron.lck\")\;\n";  
    399406        } 
    400407 
     
    530537                 
    531538                 
     539                my $shortf = Win32::GetShortPathName($gsdl);  
     540 
     541                my $command = "$shortf\\bin\\windows\\silentstart $shortf\\bin\\windows\\perl\\bin\\perl $shortf\\collect\\$colname\\cron.pl\n";  
     542                 
    532543                if($action =~ /^add$/ || $action =~ /^update$/) 
    533544                { 
     
    536547 
    537548                    if($frequency eq "hourly") { 
    538                         print $nf "50 * * * * silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     549                        print $nf "50 * * * * $command"; 
    539550                    } 
    540551                    elsif($frequency eq "daily") { 
    541                         print $nf "00 0 * * * silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     552                        print $nf "00 0 * * * $command"; 
    542553                    } 
    543554                    elsif($frequency eq "weekly") { 
    544                         print $nf "59 11 * * 0 silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     555                        print $nf "59 11 * * 0 $command"; 
    545556                    } 
    546557                    close($nf); 
     
    548559 
    549560        } else {         
     561 
     562            my $shortf = Win32::GetShortPathName($gsdl);  
     563 
     564            my $command = "$shortf\\bin\\windows\\silentstart $shortf\\bin\\windows\\perl\\bin\\perl $shortf\\collect\\$colname\\cron.pl\n";  
     565                 
     566 
    550567            if($action =~ /^add$/ || $action =~ /^update$/) 
    551568            { 
     
    553570            (&gsprintf(STDERR, "{common.cannot_open_output_file}: $!\n", $out) && die); 
    554571                if($frequency eq "hourly") { 
    555                    print $nf "50 * * * * silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     572                   print $nf "50 * * * * $command"; 
    556573                } 
    557574                elsif($frequency eq "daily") { 
    558                     print $nf "00 0 * * * silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     575                    print $nf "00 0 * * * $command"; 
    559576                } 
    560577                elsif($frequency eq "weekly") { 
    561                     print $nf "59 11 * * 0 silentstart.exe $gsdl\\collect\\$colname\\cron.pl\n"; 
     578                    print $nf "59 11 * * 0 $command"; 
    562579                } 
    563580