Notify.php
[Pman.Core] / Notify.php
index 15fb0a8..db5bc75 100644 (file)
@@ -98,6 +98,11 @@ class Pman_Core_Notify extends Pman
      */
     var $max_to_domain = 10;
     
+    /**
+     * @var $maxruntime - maximum time a child is allowed to run - defaut 2 minutes
+     */
+    var $maxruntime = 120;
+    
     var $table = 'core_notify';
     var $target = 'Core/NotifySend';
     var $evtype = ''; // any notification...
@@ -109,15 +114,15 @@ class Pman_Core_Notify extends Pman
         if (!$ff->cli) {
             die("access denied");
         }
-        HTML_FlexyFramework::ensureSingle(__FILE__, $this);
+        HTML_FlexyFramework::ensureSingle($_SERVER["SCRIPT_NAME"] .'|'. __FILE__, $this);
         return true;
-        
     }
     
     var $pool = array();
     
     function get($r,$opts)    
     {
+        print_r($r);exit;
         if ($opts['debug']) {
             DB_DataObject::debugLevel($opts['debug']);
             print_r($opts);
@@ -267,8 +272,8 @@ class Pman_Core_Notify extends Pman
         }
         
         
-        
-        die("DONE\n");
+        $this->logecho("DONE");
+        exit;
     }
     
     function run($id, $email, $cmdOpts="")
@@ -308,7 +313,7 @@ class Pman_Core_Notify extends Pman
         }
         $cmd = 'exec ' . $php . ' ' . $app . ' ' . $cmdOpts; //. ' &';
         
-       
+        print_r($cmd);exit;
         $pipe = array();
         $this->logecho("call proc_open $cmd");
         
@@ -349,8 +354,7 @@ class Pman_Core_Notify extends Pman
     {
         $pool = array();
         clearstatcache();
-        $maxruntime = 2 * 60; // 2 minutes.. ?? should be long enoguh
-        
+         
         foreach($this->pool as $p) {
              
             //echo "CHECK PID: " . $p['pid'] . "\n";
@@ -370,7 +374,7 @@ class Pman_Core_Notify extends Pman
                 //if (file_exists('/proc/'.$p['pid'])) {
                 $runtime = time() - $p['started'];
                 //echo "RUNTIME ({$p['pid']}): $runtime\n";
-                if ($runtime > $maxruntime) {
+                if ($runtime > $this->maxruntime) {
                     
                     proc_terminate($p['proc'], 9);
                     //fclose($p['pipes'][1]);
@@ -431,10 +435,11 @@ class Pman_Core_Notify extends Pman
 
     function output()
     {
-        die("Done\n");
+        $this->logecho("DONE");
+        exit;
     }
     function logecho($str)
     {
-        echo date("Y-m-d H:i:s - $str\n");
+        echo date("Y-m-d H:i:s - ") . $str . "\n";
     }
 }
\ No newline at end of file