projects
/
Pman.Core
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix #8131 - chinese translations
[Pman.Core]
/
Notify.php
diff --git
a/Notify.php
b/Notify.php
index
5a33985
..
3fd4c5b
100644
(file)
--- a/
Notify.php
+++ b/
Notify.php
@@
-178,6
+178,12
@@
class Pman_Core_Notify extends Pman
function get($r,$opts=array())
{
function get($r,$opts=array())
{
+
+ // if ($this->database_is_locked()) {
+ // die("LATER - DATABASE IS LOCKED");
+ //}
+
+
$this->parseArgs($opts);
//date_default_timezone_set('UTC');
$this->parseArgs($opts);
//date_default_timezone_set('UTC');
@@
-206,7
+212,8
@@
class Pman_Core_Notify extends Pman
$w->evtype = $this->evtype;
}
$w->evtype = $this->evtype;
}
-
+ $w->server_id = $this->server->id;
+
if (!empty($opts['old'])) {
// show old and new...
if (!empty($opts['old'])) {
// show old and new...
@@
-224,6
+231,7
@@
class Pman_Core_Notify extends Pman
if (!$this->force) {
$w->whereAdd('act_when < NOW()'); // eg.. not if future..
}
if (!$this->force) {
$w->whereAdd('act_when < NOW()'); // eg.. not if future..
}
+
$w->orderBy('act_when ASC'); // oldest first.
$total = min($w->count(), $opts['limit']);
$w->orderBy('act_when ASC'); // oldest first.
$total = min($w->count(), $opts['limit']);
@@
-232,7
+240,6
@@
class Pman_Core_Notify extends Pman
$w->limit($opts['limit']); // we can run 1000 ...
}
$w->limit($opts['limit']); // we can run 1000 ...
}
- $w->server_id = $this->server->id;
@@
-293,11
+300,14
@@
class Pman_Core_Notify extends Pman
$black = $this->server->isBlacklisted($email);
if ($black !== false) {
$black = $this->server->isBlacklisted($email);
if ($black !== false) {
-
+ $this->logecho("Blacklisted - try giving it to next server");
if (false === $this->server->updateNotifyToNextServer($p)) {
$ev = $this->addEvent('NOTIFY', $p, 'BLACKLISTED FROM our DB');
if (false === $this->server->updateNotifyToNextServer($p)) {
$ev = $this->addEvent('NOTIFY', $p, 'BLACKLISTED FROM our DB');
- $this->server->updateNotifyToNextServer($w, strtotime('NOW + 5 MINUTES'),true);
+ // we dont have an althenative server to update it with.
+ $this->logecho("Blacklisted - next server did not work - try again in 30 mins");
+ $this->server->updateNotifyToNextServer($w, date("Y-m-d H:i:s", strtotime('NOW + 30 MINUTES')),true);
// $this->errorHandler( $ev->remarks);
// $this->errorHandler( $ev->remarks);
+
}
continue;
}
continue;
@@
-401,10
+411,12
@@
class Pman_Core_Notify extends Pman
$tn = $this->tempName('stdout', true);
$tn = $this->tempName('stdout', true);
+ $tne = $this->tempName('stderr', true);
$descriptorspec = array(
0 => array("pipe", 'r'), // stdin is a pipe that the child will read from
1 => array("file", $tn, 'w'), // stdout is a pipe that the child will write to
$descriptorspec = array(
0 => array("pipe", 'r'), // stdin is a pipe that the child will read from
1 => array("file", $tn, 'w'), // stdout is a pipe that the child will write to
- 2 => array("pipe", "w") // stderr is a file to write to
+ 2 => array("file", $tne, 'w'), // stderr is a file to write to
+ // 2 => array("pipe", "w") // stderr is a file to write to
);
static $php = false;
);
static $php = false;
@@
-453,6
+465,7
@@
class Pman_Core_Notify extends Pman
'proc' => $p,
'pid' => $info['pid'],
'out' => $tn,
'proc' => $p,
'pid' => $info['pid'],
'out' => $tn,
+ 'oute' => $tne,
'cmd' => $cmd,
'email' => $email,
'pipes' => $pipes,
'cmd' => $cmd,
'email' => $email,
'pipes' => $pipes,
@@
-472,6
+485,8
@@
class Pman_Core_Notify extends Pman
foreach($this->pool as $p) {
//echo "CHECK PID: " . $p['pid'] . "\n";
foreach($this->pool as $p) {
//echo "CHECK PID: " . $p['pid'] . "\n";
+
+
$info = proc_get_status($p['proc']);
//var_dump($info);
$info = proc_get_status($p['proc']);
//var_dump($info);
@@
-493,9
+508,10
@@
class Pman_Core_Notify extends Pman
proc_terminate($p['proc'], 9);
//fclose($p['pipes'][1]);
fclose($p['pipes'][0]);
proc_terminate($p['proc'], 9);
//fclose($p['pipes'][1]);
fclose($p['pipes'][0]);
- fclose($p['pipes'][2]);
- $this->logecho("TERMINATING: ({$p['pid']}) {$p['email']} " . $p['cmd'] . " : " . file_get_contents($p['out']));
+
+ $this->logecho("TERMINATING: ({$p['pid']}) {$p['email']} " . $p['cmd'] . " : " . file_get_contents($p['out'])
. " : " . file_get_contents($p['oute'])
);
@unlink($p['out']);
@unlink($p['out']);
+ @unlink($p['oute']);
// schedule again
$w = DB_DataObject::factory($this->table);
// schedule again
$w = DB_DataObject::factory($this->table);
@@
-514,20
+530,25
@@
class Pman_Core_Notify extends Pman
continue;
}
fclose($p['pipes'][0]);
continue;
}
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']);
//echo "CLOSING: ({$p['pid']}) " . $p['cmd'] . " : " . file_get_contents($p['out']) . "\n";
//fclose($p['pipes'][1]);
proc_close($p['proc']);
-
-
+ sleep(1);
+ clearstatcache();
+ if (file_exists('/proc/'. $p['pid'])) {
+ $this->logecho("proc PID={$p['pid']} still here - trying to wait");
+ pcntl_waitpid($p['pid'], $status, WNOHANG);
+ }
+
//clearstatcache();
//if (file_exists('/proc/'.$p['pid'])) {
// $pool[] = $p;
// continue;
//}
//clearstatcache();
//if (file_exists('/proc/'.$p['pid'])) {
// $pool[] = $p;
// continue;
//}
- $this->logecho("ENDED: ({$p['pid']}) {$p['email']} " . $p['cmd'] . " : " . file_get_contents($p['out']) );
+ $this->logecho("ENDED: ({$p['pid']}) {$p['email']} " . $p['cmd'] . " : " . file_get_contents($p['out'])
. " : " . file_get_contents($p['oute'])
);
@unlink($p['out']);
@unlink($p['out']);
+ @unlink($p['oute']);
// at this point we could pop onto the queue the
$this->popQueueDomain($p['email']);
// at this point we could pop onto the queue the
$this->popQueueDomain($p['email']);
@@
-598,6
+619,7
@@
class Pman_Core_Notify extends Pman
function clearOld()
{
if ($this->server->isFirstServer()) {
function clearOld()
{
if ($this->server->isFirstServer()) {
+
$p = DB_DataObject::factory($this->table);
$p->whereAdd("
sent < '2000-01-01'
$p = DB_DataObject::factory($this->table);
$p->whereAdd("
sent < '2000-01-01'