diff --git a/core/class/Abeille.class.php b/core/class/Abeille.class.php index 918f05d64a..db5889e67b 100644 --- a/core/class/Abeille.class.php +++ b/core/class/Abeille.class.php @@ -619,12 +619,10 @@ public static function deamon_start_cleanup() { message::removeAll('Abeille'); // Remove any remaining temporary files - for ($gtwId = 1; $gtwId <= $GLOBALS['maxGateways']; $gtwId++) { - $lockFile = jeedom::getTmpFolder('Abeille').'/AbeilleLQI-Abeille'.$gtwId.'.json.lock'; - if (file_exists($lockFile)) { - unlink($lockFile); - log::add('Abeille', 'debug', 'deamon_start_cleanup(): Removed '.$lockFile); - } + $lockFile = jeedom::getTmpFolder('Abeille').'/AbeilleLQI.lock'; + if (file_exists($lockFile)) { + unlink($lockFile); + log::add('Abeille', 'debug', 'deamon_start_cleanup(): Removed '.$lockFile); } // Clear zigate IEEE status to detect any port switch. diff --git a/core/php/AbeilleLQI.php b/core/php/AbeilleLQI.php index b7a2e117fb..cc7505535e 100755 --- a/core/php/AbeilleLQI.php +++ b/core/php/AbeilleLQI.php @@ -440,6 +440,26 @@ function interrogateEq($netName, $addr, $eqIdx) { $zgEnd = $zgId; } + $tmpDir = jeedom::getTmpFolder("Abeille"); // Jeedom temp directory + + // Checking if LQI collector is already running + $lockFile = $tmpDir."/AbeilleLQI.lock"; + if (file_exists($lockFile)) { + $content = file_get_contents($lockFile); + logMessage("", "Lock content: '${content}'"); + if (substr($content, 0, 4) != "done") { + exec("pgrep -a php | grep AbeilleLQI", $running); + if (sizeof($running) != 0) { + echo 'ERROR: Collect already ongoing'; + logMessage("", "LQI collect already ongoing (lock file found) => collect canceled"); + exit; + } else { + logMessage("", "Previous LQI collect crashed. Removing lock file."); + unlink($lockFile); + } + } + } + // Collecting known equipments list logMessage("", "Known Jeedom equipments:"); $eqLogics = eqLogic::byType('Abeille'); @@ -465,7 +485,6 @@ function interrogateEq($netName, $addr, $eqIdx) { $queueParserToLQIMax = $abQueues["parserToLQI"]["max"]; msgFromParserFlush(); // Flush the queue if not empty - $tmpDir = jeedom::getTmpFolder("Abeille"); // Jeedom temp directory for ($zgId = $zgStart; $zgId <= $zgEnd; $zgId++) { if (config::byKey('ab::gtwEnabled'.$zgId, 'Abeille', 'N') != 'Y') { @@ -475,22 +494,7 @@ function interrogateEq($netName, $addr, $eqIdx) { $netName = "Abeille".$zgId; // Abeille network $newDataFile = $tmpDir."/AbeilleLQI-".$netName.".json"; // New format, replacing 'AbeilleLQI_MapDataAbeilleX.json' - $lockFile = $newDataFile.".lock"; - if (file_exists($lockFile)) { - $content = file_get_contents($lockFile); - logMessage("", $netName." lock content: '".$content."'"); - if (substr($content, 0, 4) != "done") { - exec("pgrep -a php | grep AbeilleLQI", $running); - if (sizeof($running) != 0) { - echo 'ERROR: Collect already ongoing'; - logMessage("", "LQI collect already ongoing (lock file found) => collect canceled"); - exit; - } else { - logMessage("", "Previous LQI collect crashed. Removing lock file."); - unlink($lockFile); - } - } - } + $nbwritten = file_put_contents($lockFile, "init"); if ($nbwritten < 1) { unlink($lockFile); diff --git a/desktop/js/AbeilleNetwork.js b/desktop/js/AbeilleNetwork.js index ded4ea6c32..cb7c0d76c3 100644 --- a/desktop/js/AbeilleNetwork.js +++ b/desktop/js/AbeilleNetwork.js @@ -179,7 +179,7 @@ function trackLQICollectStatus(_autoUpdate, zgId) { url: "/plugins/Abeille/core/ajax/AbeilleFiles.ajax.php", data: { action: "getTmpFile", - file: "AbeilleLQI-Abeille" + zgId + ".json.lock", + file: "AbeilleLQI.lock", }, dataType: "json", global: false, diff --git a/desktop/modal/AbeilleRefreshLQI.modal.php b/desktop/modal/AbeilleRefreshLQI.modal.php index ca2e0ec354..ea701da2e4 100644 --- a/desktop/modal/AbeilleRefreshLQI.modal.php +++ b/desktop/modal/AbeilleRefreshLQI.modal.php @@ -33,7 +33,7 @@ function analysisProgress() { url: "/plugins/Abeille/core/ajax/AbeilleFiles.ajax.php", data: { action: 'getTmpFile', - file : "AbeilleLQI-Abeille1.json.lock", + file : "AbeilleLQI.lock", }, dataType: "json", global: false, diff --git a/desktop/php/AbeilleNetworkMap.php b/desktop/php/AbeilleNetworkMap.php index dd910719d9..52d7849f9d 100644 --- a/desktop/php/AbeilleNetworkMap.php +++ b/desktop/php/AbeilleNetworkMap.php @@ -381,8 +381,7 @@ function refreshLqiProgress() { url: "/plugins/Abeille/core/ajax/AbeilleFiles.ajax.php", data: { action: 'getTmpFile', - // file : "AbeilleLQI_MapData"+Ruche+".json.lock", - file : "AbeilleLQI-"+Ruche+".json.lock", + file : "AbeilleLQI.lock", }, dataType: "json", global: false, diff --git a/docs/fr_FR/Changelog.md b/docs/fr_FR/Changelog.md index f305bed69f..89b44b9bfb 100644 --- a/docs/fr_FR/Changelog.md +++ b/docs/fr_FR/Changelog.md @@ -6,6 +6,7 @@ - Modèles TRAFRIbulbxxx: Mises-à-jour. - Assistant de découverte: Ajout 'profile ID' + 'device ID'. - Réparation: Améliorations pour support 'profile ID' + 'device ID'. +- Interne: 'AbeilleLQI-AbeilleX.json.lock' => 'AbeilleLQI.lock' ## 240610-BETA-1