feat: Add path to socket for external mariadb database (#6670)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
Diego
2026-01-18 16:44:43 +01:00
committed by GitHub
co-authored by autofix-ci[bot] Frank Elsinga
parent 999c09d818
commit a86789be6c
4 changed files with 36 additions and 13 deletions
+18 -9
View File
@@ -102,6 +102,7 @@ class SetupDatabase {
dbConfig.dbName = process.env.UPTIME_KUMA_DB_NAME;
dbConfig.username = getEnvOrFile("UPTIME_KUMA_DB_USERNAME");
dbConfig.password = getEnvOrFile("UPTIME_KUMA_DB_PASSWORD");
dbConfig.socketPath = process.env.UPTIME_KUMA_DB_SOCKET?.trim();
dbConfig.ssl = getEnvOrFile("UPTIME_KUMA_DB_SSL")?.toLowerCase() === "true";
dbConfig.ca = getEnvOrFile("UPTIME_KUMA_DB_CA");
Database.writeDBConfig(dbConfig);
@@ -160,6 +161,7 @@ class SetupDatabase {
runningSetup: this.runningSetup,
needSetup: this.needSetup,
isEnabledEmbeddedMariaDB: this.isEnabledEmbeddedMariaDB(),
isEnabledMariaDBSocket: process.env.UPTIME_KUMA_DB_SOCKET?.trim().length > 0,
});
});
@@ -202,16 +204,22 @@ class SetupDatabase {
// External MariaDB
if (dbConfig.type === "mariadb") {
if (!dbConfig.hostname) {
response.status(400).json("Hostname is required");
this.runningSetup = false;
return;
}
// If socketPath is provided and not empty, validate it
if (process.env.UPTIME_KUMA_DB_SOCKET?.trim().length > 0) {
dbConfig.socketPath = process.env.UPTIME_KUMA_DB_SOCKET.trim();
} else {
// socketPath not provided, hostname and port are required
if (!dbConfig.hostname) {
response.status(400).json("Hostname is required");
this.runningSetup = false;
return;
}
if (!dbConfig.port) {
response.status(400).json("Port is required");
this.runningSetup = false;
return;
if (!dbConfig.port) {
response.status(400).json("Port is required");
this.runningSetup = false;
return;
}
}
if (!dbConfig.dbName) {
@@ -241,6 +249,7 @@ class SetupDatabase {
user: dbConfig.username,
password: dbConfig.password,
database: dbConfig.dbName,
socketPath: dbConfig.socketPath,
...(dbConfig.ssl
? {
ssl: {