fix(cluster): ensure AstDB transactional sync, auto-healing, and Gratuitous ARP on master take-over
This commit is contained in:
1 parent
062495a162
commit
a537fc6469
4 files changed
+91
-13
No files matched your search
+12
-5
@@ -353,6 +353,9 @@ class ClusterManager
|
||||
$conf[] = " virtual_router_id {$vrid}";
|
||||
$conf[] = " priority {$prio}";
|
||||
$conf[] = " advert_int 1";
|
||||
$conf[] = " garp_master_delay 1";
|
||||
$conf[] = " garp_master_repeat 5";
|
||||
$conf[] = " garp_master_refresh 5";
|
||||
$conf[] = "";
|
||||
|
||||
// Unicast VRRP si l'IP du nœud pair est configurée (indispensable en environnement virtualisé type Proxmox/VMware)
|
||||
@@ -473,7 +476,12 @@ class ClusterManager
|
||||
@unlink($tmpAstdb);
|
||||
shell_exec("sqlite3 " . escapeshellarg($astdbPath) . " \".backup " . escapeshellarg($tmpAstdb) . "\" 2>/dev/null || cp -f " . escapeshellarg($astdbPath) . " " . escapeshellarg($tmpAstdb) . " 2>/dev/null || true");
|
||||
if (file_exists($tmpAstdb) && filesize($tmpAstdb) > 0) {
|
||||
$hasAstdb = true;
|
||||
$integrity = trim(shell_exec("sqlite3 " . escapeshellarg($tmpAstdb) . " 'PRAGMA integrity_check;' 2>/dev/null") ?? '');
|
||||
if ($integrity === 'ok') {
|
||||
$hasAstdb = true;
|
||||
} else {
|
||||
@unlink($tmpAstdb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,10 +629,9 @@ class ClusterManager
|
||||
// Restauration de l'astdb (contacts et IP actives des téléphones PJSIP)
|
||||
shell_exec("tar -xzf " . escapeshellarg($tmpArchive) . " -C /tmp astdb_cluster_sync.sqlite3 2>/dev/null || true");
|
||||
if (file_exists('/tmp/astdb_cluster_sync.sqlite3')) {
|
||||
copy('/tmp/astdb_cluster_sync.sqlite3', '/var/lib/asterisk/astdb.sqlite3');
|
||||
@chown('/var/lib/asterisk/astdb.sqlite3', 'asterisk');
|
||||
@chgrp('/var/lib/asterisk/astdb.sqlite3', 'asterisk');
|
||||
@chmod('/var/lib/asterisk/astdb.sqlite3', 0664);
|
||||
// Utilisation du helper root pour fusionner de manière transactionnelle via SQLite ATTACH
|
||||
// sans casser les descripteurs de fichiers d'Asterisk ni risquer d'écrasement corrompu
|
||||
shell_exec('sudo -n ' . escapeshellcmd(self::CLUSTER_HELPER_PATH) . ' restore-astdb /tmp/astdb_cluster_sync.sqlite3 2>&1');
|
||||
@unlink('/tmp/astdb_cluster_sync.sqlite3');
|
||||
}
|
||||
@unlink($tmpArchive);
|
||||
|
||||
Reference in new issue
Block a user