[freeside-commits] branch master updated. ff55a7842fefe34d524744c3c0d511af80429ef0

Mark Wells mark at 420.am
Tue Nov 27 19:26:13 PST 2012


The branch, master has been updated
       via  ff55a7842fefe34d524744c3c0d511af80429ef0 (commit)
      from  642bb1970300250739af3ce7a8706a9771781e05 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ff55a7842fefe34d524744c3c0d511af80429ef0
Author: Mark Wells <mark at freeside.biz>
Date:   Tue Nov 27 16:48:31 2012 -0800

    fixes for spool_upload in multiprocess mode, #6802, #18333

diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm
index 6577320..ed08a57 100644
--- a/FS/FS/Cron/upload.pm
+++ b/FS/FS/Cron/upload.pm
@@ -143,6 +143,22 @@ sub spool_upload {
   my $dbh = dbh;
 
   my $agentnum = $opt{agentnum};
+
+  # wait for any ongoing billing jobs to complete
+  # (should this exclude status='failed')?
+  if ($opt{m}) {
+    my $sql = "SELECT count(*) FROM queue LEFT JOIN cust_main USING(custnum) ".
+    "WHERE queue.job='FS::cust_main::queued_bill'";
+    $sql .= " AND cust_main.agentnum = $agentnum" if $agentnum =~ /^\d+$/;
+    my $sth = $dbh->prepare($sql) or die $dbh->errstr;
+    while (1) {
+      $sth->execute()
+        or die "Unexpected error executing statement $sql: ". $sth->errstr;
+      last if $sth->fetchrow_arrayref->[0] == 0;
+      sleep 300;
+    }
+  }
+
   my $agent;
   if ( $agentnum ) {
     $agent = qsearchs( 'agent', { agentnum => $agentnum } )
@@ -170,19 +186,6 @@ sub spool_upload {
     my $username = $opt{username} or die "no username for agent $agentnum\n";
     my $password = $opt{password} or die "no password for agent $agentnum\n";
 
-    # a better way?
-    if ($opt{m}) {
-      my $sql = "SELECT count(*) FROM queue LEFT JOIN cust_main USING(custnum) ".
-        "WHERE queue.job='FS::cust_main::queued_bill' AND cust_main.agentnum = ?";
-      my $sth = $dbh->prepare($sql) or die $dbh->errstr;
-      while (1) {
-        $sth->execute( $agentnum )
-          or die "Unexpected error executing statement $sql: ". $sth->errstr;
-        last if $sth->fetchrow_arrayref->[0];
-        sleep 300;
-      }
-    }
-
     foreach ( qw ( header detail ) ) {
       rename "$dir/$file-$_.csv",
              "$dir/$file-$date-$_.csv";
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 756b699..f136c39 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -186,7 +186,7 @@ while (1) {
       dbh->{'private_profile'} = {} if UNIVERSAL::can(dbh, 'sprintProfile');
 
       #auto-use classes...
-      if (    $ljob->job =~ /(FS::(part_export|cust_main|cust_pkg)::\w+)::/
+      if (    $ljob->job =~ /(FS::(part_export|cust_main|cust_pkg|Cron)::\w+)::/
            || $ljob->job =~ /(FS::\w+)::/
          )
       {

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

Summary of changes:
 FS/FS/Cron/upload.pm   |   29 ++++++++++++++++-------------
 FS/bin/freeside-queued |    2 +-
 2 files changed, 17 insertions(+), 14 deletions(-)




More information about the freeside-commits mailing list