Make sure the database connection is available
This commit is contained in:
parent
2ae77071e2
commit
67da2f2a3d
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
@ -84,12 +84,12 @@
|
||||||
//$interval = $settings->get('xml_cdr', '$interval');
|
//$interval = $settings->get('xml_cdr', '$interval');
|
||||||
|
|
||||||
//make sure the /var/run/fusionpbx directory exists
|
//make sure the /var/run/fusionpbx directory exists
|
||||||
if (!file_exists('/var/run/fusionpbx')) {
|
if (!file_exists('/var/run/fusionpbx')) {
|
||||||
$result = mkdir('/var/run/fusionpbx', 0777, true);
|
$result = mkdir('/var/run/fusionpbx', 0777, true);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
die('Failed to create /var/run/fusionpbx');
|
die('Failed to create /var/run/fusionpbx');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//create the process id file if the process doesn't exist
|
//create the process id file if the process doesn't exist
|
||||||
if (!$pid_exists) {
|
if (!$pid_exists) {
|
||||||
|
|
@ -110,20 +110,22 @@
|
||||||
file_put_contents($pid_file, getmypid());
|
file_put_contents($pid_file, getmypid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//import the call detail records from HTTP POST or file system
|
//import the call detail records from HTTP POST or file system
|
||||||
$cdr = new xml_cdr;
|
$cdr = new xml_cdr;
|
||||||
|
|
||||||
//get the cdr record
|
//get the cdr record
|
||||||
$xml_cdr_dir = $settings->get('switch', 'log').'/xml_cdr';
|
$xml_cdr_dir = $settings->get('switch', 'log').'/xml_cdr';
|
||||||
|
|
||||||
//loop through
|
//service loop
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
//import the call detail records from HTTP POST or file system
|
//make sure the database connection is available
|
||||||
if (!$cdr) {
|
while (!$database->is_connected()) {
|
||||||
$cdr = new xml_cdr;
|
//connect to the database
|
||||||
|
$database->connect();
|
||||||
|
|
||||||
|
//sleep for a moment
|
||||||
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//find and process cdr records
|
//find and process cdr records
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue