In the service reconnect to the database only when needed
This commit is contained in:
@@ -9,6 +9,12 @@
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set global variables
|
||||||
|
* @var database $database
|
||||||
|
*/
|
||||||
|
global $database;
|
||||||
|
|
||||||
//increase limits
|
//increase limits
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set('max_execution_time', 0);
|
ini_set('max_execution_time', 0);
|
||||||
@@ -131,6 +137,15 @@
|
|||||||
//get the messages waiting in the email queue
|
//get the messages waiting in the email queue
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
//connect to the database if needed
|
||||||
|
if (!$database->is_connected()) {
|
||||||
|
$database->connect();
|
||||||
|
if (!$database->is_connected()) {
|
||||||
|
sleep(3);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//get the messages that are waiting to send
|
//get the messages that are waiting to send
|
||||||
$sql = "select * from v_email_queue ";
|
$sql = "select * from v_email_queue ";
|
||||||
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
|
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
|
||||||
@@ -139,7 +154,6 @@
|
|||||||
$sql .= "limit :limit ";
|
$sql .= "limit :limit ";
|
||||||
$parameters['hostname'] = $hostname;
|
$parameters['hostname'] = $hostname;
|
||||||
$parameters['limit'] = $email_queue_limit;
|
$parameters['limit'] = $email_queue_limit;
|
||||||
$database = new database;
|
|
||||||
$email_queue = $database->select($sql, $parameters, 'all');
|
$email_queue = $database->select($sql, $parameters, 'all');
|
||||||
unset($parameters);
|
unset($parameters);
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
$pid = file_get_contents($file);
|
$pid = file_get_contents($file);
|
||||||
if (function_exists('posix_getsid')) {
|
if (function_exists('posix_getsid')) {
|
||||||
if (posix_getsid($pid) === false) {
|
if (posix_getsid($pid) === false) {
|
||||||
//process is not running
|
//process is not running
|
||||||
$exists = false;
|
$exists = false;
|
||||||
}
|
}
|
||||||
@@ -136,6 +136,15 @@
|
|||||||
//get the messages waiting in the fax queue
|
//get the messages waiting in the fax queue
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
|
//connect to the database if needed
|
||||||
|
if (!$database->is_connected()) {
|
||||||
|
$database->connect();
|
||||||
|
if (!$database->is_connected()) {
|
||||||
|
sleep(3);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//get the fax messages that are waiting to send
|
//get the fax messages that are waiting to send
|
||||||
$sql = "select * from v_fax_queue ";
|
$sql = "select * from v_fax_queue ";
|
||||||
$sql .= "where hostname = :hostname ";
|
$sql .= "where hostname = :hostname ";
|
||||||
@@ -164,7 +173,6 @@
|
|||||||
echo $sql."\n";
|
echo $sql."\n";
|
||||||
print_r($parameters);
|
print_r($parameters);
|
||||||
}
|
}
|
||||||
$database = new database;
|
|
||||||
$fax_queue = $database->select($sql, $parameters, 'all');
|
$fax_queue = $database->select($sql, $parameters, 'all');
|
||||||
unset($parameters);
|
unset($parameters);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user