$this->_file = "$dir/$name.pid";
if (file_exists($this->_file)) {
- $pid = trim(file_get_contents($this->_file));
- if (posix_kill($pid, 0)) {
+ $pid = trim(@file_get_contents($this->_file));
+ if (($pid != "") AND posix_kill($pid, 0)) {
$this->_running = true;
}
}
public function __destruct() {
if ((! $this->_running) && file_exists($this->_file)) {
- unlink($this->_file);
+ @unlink($this->_file);
}
}
}
public function running_time() {
- return(time() - filectime($this->_file));
+ return(time() - @filectime($this->_file));
}
public function kill() {
if ($workers[0]["workers"] >= $queues)
return;
+ $starttime = time();
+
while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `created` LIMIT 1")) {
if(function_exists('sys_getloadavg')) {
}
}
+ // Quit the poller once every hour
+ if (time() > ($starttime + 3600))
+ return;
+
q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d",
dbesc(datetime_convert()),
intval(getmypid()),