Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:45:15

0001 #!/usr/bin/env perl
0002 #     R. Mankel, DESY Hamburg     17-Oct-2007
0003 #     A. Parenti, DESY Hamburg    16-Apr-2008
0004 #     $Revision: 1.6 $
0005 #     $Date: 2010/08/12 12:55:08 $
0006 #
0007 #  Try periodically to fire merge job.
0008 #  Terminate when done
0009 #
0010 #  Usage: mps_auto.pl seconds
0011 #
0012 
0013 BEGIN {
0014 use File::Basename;
0015 unshift(@INC, dirname($0)."/mpslib");
0016 }
0017 use Mpslib;
0018 
0019 $seconds = 60;
0020 
0021 # parse the arguments
0022 while (@ARGV) {
0023   $arg = shift(ARGV);
0024   if ($arg =~ /\A-/) {  # check for option 
0025     if ($arg =~ "h") {
0026       $helpwanted = 1;
0027     }
0028     elsif ($arg =~ "d") {
0029       $localdir = 1;
0030     }
0031     $optionstring = "$optionstring$arg";
0032   }
0033   else {                # parameters not related to options
0034     $i = $i + 1;
0035     if ($i eq 1) {
0036       $seconds = $arg;
0037     }
0038   }
0039 }
0040 
0041 if ($helpwanted != 0 ) {
0042   print "Usage:\n  mps_auto.pl [options] [seconds]";
0043   print "\nTry to submit merge job every 'seconds' (default: 60, min: 20) seconds.";
0044   print "\nStops in case of a problem in a mille job.";
0045   print "\nKnown options:";
0046   print "\n -h   This help.\n";
0047   exit;
0048 }
0049 
0050 
0051 if ($seconds <20) {
0052   print "Set seconds to 20\n";
0053   $seconds = 20;
0054 }
0055 
0056 $done = 0;
0057 
0058 $iter = 0;
0059 while ($done == 0) {
0060   if ($iter != 0) {
0061     print  "mps_stat.py > /dev/null; mps_fetch.py\n";
0062     system "mps_stat.py > /dev/null; mps_fetch.py";
0063     read_db();
0064     # loop over mille jobs
0065     for ($i=0; $i<$nJobs; ++$i) {
0066      if ($JOBSTATUS[$i] ne "RUN" && $JOBSTATUS[$i] ne "DONE" 
0067          && $JOBSTATUS[$i] ne "OK" && $JOBSTATUS[$i] ne  "PEND"
0068              && !$JOBSTATUS[$i] =~ /DISABLED/) {
0069          $done = 1;
0070          print "Mille job $i in unknown or bad status $JOBSTATUS[$i], stopping.\n";
0071      }
0072     }
0073     if ($done == 0) { # only in case of no problem...
0074     print  "mps_fire.py -m; date; sleep $seconds\n";
0075     system "mps_fire.py -m; date; sleep $seconds";
0076     }
0077   }
0078   $iter = $iter + 1;
0079   # go to merge job 
0080   read_db();
0081   $i = (@JOBID) - 1;
0082   if (@JOBSTATUS[$i] ne "SETUP") {
0083     $done = 1;
0084     break;
0085   }
0086 }