DataObjects/core.sql
[Pman.Core] / Notify.php
index 73c4805..6d99ac5 100644 (file)
@@ -90,7 +90,10 @@ class Pman_Core_Notify extends Pman
         if (!empty($opts['send-to'])) {
             $this->send_to = $opts['send-to'];
         }
-     
+        
+        $w = DB_DataObject::factory('core_notify_recur');
+        $w->generateNotifications();
+        
         //DB_DataObject::debugLevel(1);
         $w = DB_DataObject::factory($this->table);
         
@@ -188,7 +191,7 @@ class Pman_Core_Notify extends Pman
         $php = $_SERVER["_"];
         $sn =  $_SERVER["SCRIPT_NAME"];
         
-        $cwd = $sn[0] == '/' ? dirname($sn) : dirname(realpath(getcwd() . $sn)); // same as run on.. (so script should end up being same relatively..)
+        $cwd = $sn[0] == '/' ? dirname($sn) : dirname(realpath(getcwd() . '/'. $sn)); // same as run on.. (so script should end up being same relatively..)
         $app = $cwd . '/' . basename($_SERVER["SCRIPT_NAME"]) . '  ' . $this->target . '/'. $id;
         if ($this->force) {
             $app .= ' -f';
@@ -238,15 +241,15 @@ class Pman_Core_Notify extends Pman
             
                 //if (file_exists('/proc/'.$p['pid'])) {
                 $runtime = time() - $p['started'];
-                echo "RUNTIME ({$p['pid']}): $runtime\n";
+                //echo "RUNTIME ({$p['pid']}): $runtime\n";
                 if ($runtime > $maxruntime) {
                     
-                    proc_terminate($p['proc']);
-                    echo "TERMINATING: ({$p['pid']}) " . $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
+                    proc_terminate($p['proc'], 9);
                     //fclose($p['pipes'][1]);
                     fclose($p['pipes'][0]);
                     fclose($p['pipes'][2]);
-                    
+                    echo "TERMINATING: ({$p['pid']}) " . $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
+                    @unlink($p['out']);
                     
                     continue;
                 }
@@ -254,21 +257,21 @@ class Pman_Core_Notify extends Pman
                 $pool[] = $p;
                 continue;
             }
-            
-            echo "CLOSING: ({$p['pid']}) " . $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
-            //fclose($p['pipes'][1]);
             fclose($p['pipes'][0]);
             fclose($p['pipes'][2]);
+            //echo "CLOSING: ({$p['pid']}) " . $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
+            //fclose($p['pipes'][1]);
+            
             proc_close($p['proc']);
             
             
-            clearstatcache();
-            if (file_exists('/proc/'.$p['pid'])) {
-                $pool[] = $p;
-                continue;
-            }
+            //clearstatcache();
+            //if (file_exists('/proc/'.$p['pid'])) {
+            //    $pool[] = $p;
+            //    continue;
+            //}
             echo "ENDED: ({$p['pid']}) " .  $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
-            
+            @unlink($p['out']);
             //unlink($p['out']);
         }
         echo "POOL SIZE: ". count($pool) ."\n";