2 require_once 'Pman.php';
5 * notification script runner
7 * This does not actualy send stuf out, it only starts the NotifySend/{id}
8 * which does the actuall notifcations.
10 * It manages a pool of notifiers.
16 class Pman_Core_NotifySend extends Pman
19 var $table = 'core_notify'
22 $ff = HTML_FlexyFramework::get();
26 //HTML_FlexyFramework::ensureSingle(__FILE__, $this);
35 DB_DataObject::debugLevel(1);
36 //date_default_timezone_set('UTC');
39 $w = DB_DataObject::factory($this->table);
41 if (!$w->get($id) || strtotime($w->act_when) < strtotime($w->sent)) {
42 die("invalid id or time");
50 $descriptorspec = array(
51 0 => array("file", "/dev/null", 'r'), // stdin is a pipe that the child will read from
52 1 => array("file", "/dev/null", 'a'), // stdout is a pipe that the child will write to
53 2 => array("file", "/dev/null", "a") // stderr is a file to write to
56 $cwd = getcwd(); // same as run on.. (so script should end up being same relatively..)
57 $app = $cwd . '/'. $_SERVER["SCRIPT_NAME"] . ' ' . $this->target . '/'. $id;
58 $cmd = $php . ' ' . $app;
61 $p = proc_open($cmd, $descriptorspec, $pipes, $cwd );
67 foreach($this->pool as $p) {
68 $ar = proc_get_Status($p);
75 if (count($pool) < 10) {