Notify.php
[Pman.Core] / Notify.php
index 9106b40..7e4f65e 100644 (file)
@@ -86,6 +86,7 @@ class Pman_Core_Notify extends Pman
         ),
     );
     
+    
     var $max_pool_size = 10;
     
     var $table = 'core_notify';
@@ -197,6 +198,7 @@ class Pman_Core_Notify extends Pman
         
         //echo "BATCH SIZE: ".  count($ar) . "\n";
         $pushed = array();
+        $requeue = array();
         while (true) {
             
             
@@ -209,7 +211,7 @@ class Pman_Core_Notify extends Pman
                     break;
                 }
                 $ar = $pushed;
-                $pushed = array();
+                $pushed = false;
                 continue;
             }
             
@@ -222,6 +224,11 @@ class Pman_Core_Notify extends Pman
             }
             if ($this->poolHasDomain($p->person_id_email)) {
                 
+                if ($pushed === false) {
+                    // we only try once to requeue..
+                    $requeue[] = $p;
+                    continue;
+                }
                 $pushed[] = $p;
                 
                 
@@ -242,12 +249,29 @@ class Pman_Core_Notify extends Pman
              sleep(3);
         }
         
+        
+        foreach($requeue as $p) {
+            $pp = clone($p);
+            $p->event_when = strtotime($p->event_when .  ' + 1 MINUTE');
+            $p->update($pp);
+            
+        }
+        
+        
+        
         die("DONE\n");
     }
     
     function run($id, $email, $cmdOpts="")
     {
-       // phpinfo();exit;
+        
+        static $renice = fase;
+        if (!$renice) {
+            require_once 'System.php';
+            $renice = System::which('renice');
+        }
+        
+        // phpinfo();exit;
         $tn = tempnam(ini_get('session.save_path'),'stdout') . '.stdout';
         $descriptorspec = array(
             0 => array("pipe", 'r'),  // stdin is a pipe that the child will read from
@@ -272,6 +296,12 @@ class Pman_Core_Notify extends Pman
         echo "call proc_open $cmd\n";
         
         
+        if ($this->max_pool_size === 1) {
+            passthru($cmd);
+            return;
+        }
+        
+        
         if (!empty($this->opts['dryrun'])) {
             echo "DRY RUN\n";
             return;