From 609728387742c8d7f2900232eb13104369802e38 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 7 Apr 2011 15:19:17 +0800 Subject: [PATCH] Notify.php --- Notify.php | 103 ----------------------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 Notify.php diff --git a/Notify.php b/Notify.php deleted file mode 100644 index 7a418945..00000000 --- a/Notify.php +++ /dev/null @@ -1,103 +0,0 @@ -cli) { - die("access denied"); - } - HTML_FlexyFramework::ensureSingle(__FILE__, $this); - return true; - - } - - var $pool = array(); - - function get() - { - DB_DataObject::debugLevel(1); - //date_default_timezone_set('UTC'); - // phpinfo();exit; - - $w = DB_DataObject::factory($this->table); - $w->whereAdd('act_when > sent'); // eg.. sent is not valid.. - $w->whereAdd('act_when > NOW()'); // eg.. not if future.. - - $w->orderBy('act_when ASC'); // oldest first. - $w->limit(1000); // we can run 1000 ... - $ar = $w->fetchAll('id'); - - while (true) { - if (empty($ar)) { - break; - } - if (!$this->poolfree()) { - sleep(3); - continue; - } - $p = array_shift($ar); - $this->run($p); - } - while(count($this->pool)) { - $this->poolfree(); - sleep(3); - } - - die("DONE\n"); - } - - function run($id) - { - $descriptorspec = array( - 0 => array("file", "/dev/null", 'r'), // stdin is a pipe that the child will read from - 1 => array("file", "/dev/null", 'a'), // stdout is a pipe that the child will write to - 2 => array("file", "/dev/null", "a") // stderr is a file to write to - ); - $php = $_SERVER["_"]; - $cwd = getcwd(); // same as run on.. (so script should end up being same relatively..) - $app = $cwd . '/'. $_SERVER["SCRIPT_NAME"] . ' ' . $this->target . '/'. $id; - $cmd = $php . ' ' . $app; - echo $cmd . "\n"; - $pipe = array(); - $p = proc_open($cmd, $descriptorspec, $pipes, $cwd ); - $this->pool[] = $p; - } - - function poolfree() { - $pool = array(); - foreach($this->pool as $p) { - $ar = proc_get_Status($p); - //var_dump($ar); - if ($p['running']) { - $pool[] = $p; - } - } - $this->pool = $pool; - if (count($pool) < 10) { - return true; - } - return false; - - } - - -} \ No newline at end of file -- 2.39.2