You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2005/11/12 01:59:58 UTC

svn commit: r332694 - in /spamassassin/trunk: build/automc/buildbot_ready build/automc/freqsd masses/mass-check

Author: jm
Date: Fri Nov 11 16:59:52 2005
New Revision: 332694

URL: http://svn.apache.org/viewcvs?rev=332694&view=rev
Log:
major revamp; I was trying to avoid using IPC::DirQueue, but it just makes a lot more sense

Modified:
    spamassassin/trunk/build/automc/buildbot_ready
    spamassassin/trunk/build/automc/freqsd
    spamassassin/trunk/masses/mass-check

Modified: spamassassin/trunk/build/automc/buildbot_ready
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/automc/buildbot_ready?rev=332694&r1=332693&r2=332694&view=diff
==============================================================================
--- spamassassin/trunk/build/automc/buildbot_ready (original)
+++ spamassassin/trunk/build/automc/buildbot_ready Fri Nov 11 16:59:52 2005
@@ -95,12 +95,13 @@
   run ("mv ham.log $logdir/ham-$slave.log");
   run ("mv spam.log $logdir/spam-$slave.log");
 
-  # now, generate the reports
-  $ENV{HOME} = '/home/bbmass';
-  umask(022);
+  # enqueue a request with the report-generation daemon
+  run ("../build/automc/freqsd --enq $logdir");
 
-  run ("./rule-qa/corpus-hourly --dir $logdir");
-  run ("./rule-qa/automc/gen_info_xml");
+  # $ENV{HOME} = '/home/bbmass';
+  # umask(022);
+  # run ("./rule-qa/corpus-hourly --dir $logdir");
+  # run ("./rule-qa/automc/gen_info_xml");
 }
 
 # ---------------------------------------------------------------------------
@@ -108,10 +109,15 @@
 sub get_current_svn_revision {
   open (SVNINFO, "(svn info --non-interactive || svn info) < /dev/null 2>&1 |");
 
+  # note: use 'Last Changed Rev' instead of 'Revision'.  Because we share
+  # an SVN repository with other projects, this means that the same
+  # rev of *our* codebase may appear under multiple rev#s, as other projects
+  # check their changes in.
+
   my $revision;
   while (<SVNINFO>) {
-    # Revision: 320871
-    next unless /^Revision: (\d+)/;
+    # Last Changed Rev: 332684
+    next unless /^Last Changed Rev: (\d+)/;
     $revision = $1;
     last;
   }

Modified: spamassassin/trunk/build/automc/freqsd
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/build/automc/freqsd?rev=332694&r1=332693&r2=332694&view=diff
==============================================================================
--- spamassassin/trunk/build/automc/freqsd (original)
+++ spamassassin/trunk/build/automc/freqsd Fri Nov 11 16:59:52 2005
@@ -4,35 +4,29 @@
 use warnings;
 
 use Getopt::Long;
+use IPC::DirQueue;
 
 use vars qw(
     $pidfile
-    $opt_wake
+    $opt_enq
 );
 GetOptions(
     "pidfile=s" => \$pidfile,
-    "wake" => \$opt_wake,
+    "enq=s" => \$opt_enq,
 );
 
-if ($opt_wake) {
-  die "wake needs pidfile" if (!$pidfile);
-  open(IN, "<$pidfile") or die "cannot read $pidfile";
-  my $pid = <IN> + 0;
-  close IN;
+my $dq_fast = IPC::DirQueue->new({ dir => "/home/automc/freqsd/dq_fast" });
+my $dq_slow = IPC::DirQueue->new({ dir => "/home/automc/freqsd/dq_slow" });
+$pidfile ||= "/home/automc/freqsd/pid";
 
-  if ($pid <= 1) {
-    die "pid out of range: $pid";
-  }
-
-  kill (1,$pid) or die "kill -1 $pid failed";
-  print "signalled $pid\n";
-  exit;
-}
+$ENV{HOME} = '/home/bbmass';
+umask(022);
 
 # ---------------------------------------------------------------------------
 
 # by separating this into two processes, we can get the parent reports issued
-# immediately, and the slow reports can gronk away in the background
+# immediately, and the slow reports can gronk away in the background.
+# by using IPC::DirQueue,
 
 # the parent process continually generates the faster reports
 my $parent_reports = "LOGS.all DETAILS.new DETAILS.all DETAILS.age ".
@@ -46,6 +40,15 @@
 
 # ---------------------------------------------------------------------------
 
+if ($opt_enq) {
+  $dq_fast->enqueue_string("", { dir => $opt_enq });
+  $dq_slow->enqueue_string("", { dir => $opt_enq });
+  exit;
+}
+
+# ---------------------------------------------------------------------------
+
+sub run;
 my $am_parent;
 my $child_pid = fork();
 if ($child_pid < 0) {
@@ -58,7 +61,6 @@
   $am_parent = 1;
 }
 
-$SIG{HUP} = \&sighup_handler;
 $SIG{INT} = \&sigterm_handler;
 $SIG{TERM} = \&sigterm_handler;
 
@@ -68,11 +70,13 @@
   close OUT or die "cannot save $pidfile";
 }
 
-while (1) {
-  if ($am_parent) {
+if ($am_parent) {
+  while (1) {
     parent_loop();
   }
-  else {
+}
+else {
+  while (1) {
     child_loop();
   }
 }
@@ -80,31 +84,49 @@
 # ---------------------------------------------------------------------------
 
 sub parent_loop {
+  my $job = $dq_fast->wait_for_queued_job($idle_sleep);
+
   print "starting faster reports ($$) at ".(scalar localtime time)."\n";
-  system ("cd masses/rule-qa; ./corpus-hourly ".
-        "--override='output_classes=$parent_reports'");
+
+  # add optional --dir switch
+  my $logdir = '';
+  if ($job->{metadata}->{dir}) {
+    $logdir = "--dir ".$job->{metadata}->{dir};
+  }
+
+  run ("cd masses/rule-qa ; ./corpus-hourly ".
+        "--override='output_classes=$parent_reports' ".
+        "$logdir");
+
+  run ("cd masses ; ./rule-qa/automc/gen_info_xml");
+
   print "completed faster reports ($$) at ".(scalar localtime time)."\n";
 
-  sleep $idle_sleep;        # sleep until timeout, or we get SIGHUPped
+  if ($job) {
+    $job->finish();
+  }
 }
 
 # ---------------------------------------------------------------------------
 
 sub child_loop {
+  my $job = $dq_fast->wait_for_queued_job($idle_sleep);
+
   print "starting slow reports ($$) at ".(scalar localtime time)."\n";
-  system ("cd masses/rule-qa; ./corpus-hourly ".
-        "--override='output_classes=$child_reports'");
-  print "completed slow reports ($$) at ".(scalar localtime time)."\n";
 
-  sleep $idle_sleep;        # sleep until timeout, or we get SIGHUPped
-}
+  # add optional --dir switch
+  my $logdir = '';
+  if ($job->{metadata}->{dir}) {
+    $logdir = "--dir ".$job->{metadata}->{dir};
+  }
 
-# ---------------------------------------------------------------------------
+  run ("cd masses/rule-qa; ./corpus-hourly ".
+        "--override='output_classes=$child_reports' ".
+        "$logdir");
 
-sub sighup_handler {
-  warn "received SIGHUP at ".(scalar localtime time)."\n";
-  # this SIGHUP will interrupt a sleep() if one is in progress
-  if ($am_parent) { kill(1, $child_pid); } # pass it on
+  print "completed slow reports ($$) at ".(scalar localtime time)."\n";
+
+  sleep $idle_sleep;        # sleep until timeout, or we get SIGHUPped
 }
 
 # ---------------------------------------------------------------------------
@@ -116,4 +138,16 @@
   die "terminated";
 }
 
+# ---------------------------------------------------------------------------
+
+sub run {
+  my ($cmd, $ignoreexit) = @_;
+
+  print "[$cmd]\n";
+  system ($cmd);
+
+  if (!$ignoreexit) {
+    die "command '$cmd' failed with status $?" if (($? >> 8) != 0);
+  }
+}
 

Modified: spamassassin/trunk/masses/mass-check
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/masses/mass-check?rev=332694&r1=332693&r2=332694&view=diff
==============================================================================
--- spamassassin/trunk/masses/mass-check (original)
+++ spamassassin/trunk/masses/mass-check Fri Nov 11 16:59:52 2005
@@ -690,8 +690,8 @@
     }
 
     while (<SVNINFO>) {
-      # Revision: 320871
-      next unless /^Revision: (\d+)/;
+      # Last Changed Rev: 320871
+      next unless /^Last Changed Rev: (\d+)/;
       $revision = $1;
       last;
     }