perf(db): eliminate redundant DDL execution on every request and add nexus-cluster to update.sh sudoers
This commit is contained in:
1 parent
c93b52d99c
commit
d2e3be3356
2 files changed
+11
-4
No files matched your search
+1
-1
@@ -112,7 +112,7 @@ ln -sf "$APP_DIR/scripts/nexus-banner.sh" /usr/local/bin/nexus-banner 2>/dev/nul
|
||||
# Mise à jour des privilèges sudoers (www-data) si accessible en écriture
|
||||
if [ -w /etc/sudoers.d ]; then
|
||||
cat << 'EOF_SUDO' > /etc/sudoers.d/nexus-pbx 2>/dev/null || true
|
||||
www-data ALL=(ALL) NOPASSWD: /usr/sbin/asterisk, /usr/sbin/nginx, /usr/bin/systemctl, /usr/bin/fail2ban-client, /bin/fail2ban-client, /var/www/nexus-pbx/scripts/nexus-firewall, /usr/bin/certbot, /usr/sbin/nft, /usr/sbin/iptables, /var/www/nexus-pbx/scripts/update.sh, /usr/local/bin/nexus-update
|
||||
www-data ALL=(ALL) NOPASSWD: /usr/sbin/asterisk, /usr/sbin/nginx, /usr/bin/systemctl, /usr/bin/fail2ban-client, /bin/fail2ban-client, /var/www/nexus-pbx/scripts/nexus-firewall, /usr/bin/certbot, /usr/sbin/nft, /usr/sbin/iptables, /var/www/nexus-pbx/scripts/update.sh, /usr/local/bin/nexus-update, /var/www/nexus-pbx/scripts/nexus-cluster
|
||||
EOF_SUDO
|
||||
chmod 0440 /etc/sudoers.d/nexus-pbx 2>/dev/null || true
|
||||
fi
|
||||
|
||||
+10
-3
@@ -29,7 +29,7 @@ class Database
|
||||
mkdir($dir, 0770, true);
|
||||
}
|
||||
|
||||
$isNew = !file_exists(self::DB_PATH);
|
||||
$isNew = !file_exists(self::DB_PATH) || filesize(self::DB_PATH) === 0;
|
||||
|
||||
self::$instance = new PDO('sqlite:' . self::DB_PATH, null, null, [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
@@ -41,10 +41,17 @@ class Database
|
||||
self::$instance->exec('PRAGMA journal_mode = WAL;');
|
||||
self::$instance->exec('PRAGMA busy_timeout = 5000;');
|
||||
|
||||
self::initializeSchema();
|
||||
|
||||
if ($isNew) {
|
||||
self::initializeSchema();
|
||||
@chmod(self::DB_PATH, 0660);
|
||||
} else {
|
||||
// Si la base existe déjà, éviter d'exécuter l'intégralité du DDL à chaque requête HTTP
|
||||
// ce qui sature SQLite de verrous exclusifs inutiles. On teste juste l'existence de la table principale.
|
||||
try {
|
||||
self::$instance->query("SELECT 1 FROM settings LIMIT 1");
|
||||
} catch (\Throwable $e) {
|
||||
self::initializeSchema();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user