In the service reconnect to the database only when needed

This commit is contained in:
markjcrane
2025-11-15 08:29:51 -07:00
parent 96a0355d1d
commit ffa86100b2
2 changed files with 25 additions and 3 deletions

View File

@@ -46,7 +46,7 @@
if (file_exists($file)) {
$pid = file_get_contents($file);
if (function_exists('posix_getsid')) {
if (posix_getsid($pid) === false) {
if (posix_getsid($pid) === false) {
//process is not running
$exists = false;
}
@@ -136,6 +136,15 @@
//get the messages waiting in the fax queue
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
$sql = "select * from v_fax_queue ";
$sql .= "where hostname = :hostname ";
@@ -164,7 +173,6 @@
echo $sql."\n";
print_r($parameters);
}
$database = new database;
$fax_queue = $database->select($sql, $parameters, 'all');
unset($parameters);