1
0

adding command test in apiserver\nsome debugging\nfree sms now running fine

This commit is contained in:
2022-07-10 19:33:19 +02:00
parent 97f8050d29
commit 555abb7c88
14 changed files with 182 additions and 66 deletions

View File

@ -50,7 +50,7 @@ if ($testMode)
$httpServerIp = "192.168.1.253";
}else
{
$logLevel = INFO | NOTICE | WARNING | ERROR | ALERT;
$logLevel = DEBUG | INFO | NOTICE | WARNING | ERROR | ALERT;
$mqttServerIp = "127.0.0.1"; // IP address of mqttserver in production mode
$dataPath = "/usr/share/moha/";
$logFile = "/var/log/moha.log"; // Path of log file
@ -64,13 +64,13 @@ if (!init()) exit(1);
bindtextdomain("moha", "./locale");
textdomain("moha");
function notify($message)
function notify($message, $destinataire=NOTIF_DEFAULT_DEST)
{
global $notificationMethods;
$result = false;
foreach($notificationMethods as $value)
{
$result = $result | $value->send($message);
$result = $result | $value->send($message, $destinataire);
}
return $result;
}
@ -95,8 +95,10 @@ function logger($level, $log, $pos = "", $notif = true)
if(notify("Moha\n" . $logString) === false)
{
logger(INFO, _("Notification not sent"), __FILE__ . ":" . __LINE__, false);
return true;
}
}
return false;
}
function init()
@ -200,6 +202,18 @@ require "events.php";
require "db_functions.php";
require "apiserver/apiserver.php";
logger(DEBUG, _("Loading stored events datas from ") . $dataPath . "events.db", __FILE__ . ":" . __LINE__);
if (file_exists($dataPath . "events.db"))
{
if (($db = loadDB($dataPath . "events.db")) === false)
{
logger(ERROR, _("Can not load events db"), __FILE__ . ":" . __LINE__);
}else
{
$events = $db;
}
}
// topics definition
listHooks("./topics_callbacks", $topicsCallbacks);
if (!empty($topicsCallbacks))
@ -236,6 +250,11 @@ if (file_exists($dataPath . "topics.db"))
}else
{
$topics = $db;
foreach($topics as $topicName => $topic )
{
$topic->notificationSent = false;
logger(DEBUG, "topic: " . $topicName . " is " . bool2string($topic->notificationSent));
}
}
}
@ -253,18 +272,7 @@ if (file_exists($dataPath . "devices.db"))
}
}
logger(DEBUG, _("Loading stored events datas from ") . $dataPath . "events.db", __FILE__ . ":" . __LINE__);
if (file_exists($dataPath . "events.db"))
{
if (($db = loadDB($dataPath . "events.db")) === false)
{
logger(ERROR, _("Can not load events db"), __FILE__ . ":" . __LINE__);
}else
{
$events = $db;
}
}
// Program start
logger(DEBUG, _("Program start"), __FILE__ . ":" . __LINE__, false);
@ -338,6 +346,7 @@ while (true)
//logger(DEBUG, _("looping"), __FILE__ . ":" . __LINE__);
}
checkEvents();
checkTopicsAvailability();
if ($apiServerIsActive) apiServer($read);
}