Updates
This commit is contained in:
@@ -269,6 +269,10 @@ export default function grabDirNames(param?: Param) {
|
||||
distroDirName
|
||||
);
|
||||
|
||||
const tempBackupExportName = "tmp-export-backup.tar.xz";
|
||||
|
||||
const opsJSONFileName = "ops.json";
|
||||
|
||||
return {
|
||||
appDir,
|
||||
privateDataDir,
|
||||
@@ -362,5 +366,7 @@ export default function grabDirNames(param?: Param) {
|
||||
dsqlDbDockerComposeFileAlt,
|
||||
dsqlDbDockerComposeFileName,
|
||||
dsqlDbDockerComposeFileNameAlt,
|
||||
tempBackupExportName,
|
||||
opsJSONFileName,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
export default function grabDockerStackServicesNames() {
|
||||
const deploymentName = process.env.DSQL_DEPLOYMENT_NAME || "dsql";
|
||||
type Params = {
|
||||
deploymentName?: string | null;
|
||||
};
|
||||
|
||||
export default function grabDockerStackServicesNames(params?: Params) {
|
||||
const deploymentName =
|
||||
params?.deploymentName || process.env.DSQL_DEPLOYMENT_NAME || "dsql";
|
||||
|
||||
const maxScaleServiceName = `${deploymentName}-dsql-maxscale`;
|
||||
const dbServiceName = `${deploymentName}-dsql-db`;
|
||||
|
||||
@@ -21,6 +21,7 @@ export default function grabIPAddresses() {
|
||||
const mainDBIP = `${globalIPPrefix}.${db}`;
|
||||
const webSocketIP = `${globalIPPrefix}.${websocket}`;
|
||||
const dbCronIP = `${globalIPPrefix}.${db_cron}`;
|
||||
const reverseProxyIP = `${globalIPPrefix}.${reverse_proxy}`;
|
||||
const localHostIP = `${globalIPPrefix}.1`;
|
||||
|
||||
return {
|
||||
@@ -32,5 +33,6 @@ export default function grabIPAddresses() {
|
||||
globalIPPrefix,
|
||||
webSocketIP,
|
||||
dbCronIP,
|
||||
reverseProxyIP,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export default function genRndStr(length?: number, symbols?: boolean) {
|
||||
let characters =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
if (symbols) characters += "-_[]()@";
|
||||
|
||||
let result = "";
|
||||
|
||||
const finalLength = length || 12;
|
||||
|
||||
for (let i = 0; i < finalLength; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
result += characters.charAt(randomIndex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { networkInterfaces } from "os";
|
||||
|
||||
export default function getMachineIPAddress() {
|
||||
try {
|
||||
const interfaces = networkInterfaces();
|
||||
for (const ifaceName in interfaces) {
|
||||
const iface = interfaces[ifaceName];
|
||||
if (Array.isArray(iface)) {
|
||||
for (const address of iface) {
|
||||
if (address.family === "IPv4" && !address.internal) {
|
||||
return address.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (error: any) {
|
||||
console.error(`Error accessing network interfaces: ${error.message}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ export default function grabUserMainSqlUserName({
|
||||
|
||||
const finalUsername = username || sqlUsername;
|
||||
const finalHost = HOST || maxScaleIP || "127.0.0.1";
|
||||
const fullName = `${finalUsername}@${webAppIP}`;
|
||||
const fullName = `${finalUsername}@${finalHost}`;
|
||||
|
||||
return {
|
||||
username: finalUsername,
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import grabDbSSL from "./backend/grabDbSSL";
|
||||
import mariadb, { ConnectionConfig } from "mariadb";
|
||||
|
||||
type Params = {
|
||||
useLocal?: boolean;
|
||||
dbConfig?: ConnectionConfig;
|
||||
ssl?: boolean;
|
||||
connectionLimit?: number;
|
||||
};
|
||||
|
||||
export default async function setupDSQLDb({ dbConfig, ssl }: Params) {
|
||||
const conn = await mariadb.createConnection({
|
||||
host: process.env.DSQL_DB_HOST,
|
||||
user: process.env.DSQL_DB_USERNAME,
|
||||
password: process.env.DSQL_DB_PASSWORD,
|
||||
database: process.env.DSQL_DB_NAME,
|
||||
charset: "utf8mb4",
|
||||
...dbConfig,
|
||||
ssl: ssl ? grabDbSSL() : undefined,
|
||||
supportBigNumbers: true,
|
||||
bigNumberStrings: false,
|
||||
dateStrings: true,
|
||||
bigIntAsNumber: true,
|
||||
metaAsArray: true,
|
||||
});
|
||||
|
||||
// const conn = mariadb.createPool({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_USERNAME,
|
||||
// password: process.env.DSQL_DB_PASSWORD,
|
||||
// database: process.env.DSQL_DB_NAME,
|
||||
// charset: "utf8mb4",
|
||||
// ...dbConfig,
|
||||
// ssl: ssl ? grabDbSSL() : undefined,
|
||||
// connectionLimit,
|
||||
// supportBigNumbers: true,
|
||||
// bigNumberStrings: false,
|
||||
// dateStrings: true,
|
||||
// });
|
||||
|
||||
// let readOnlyConnection;
|
||||
|
||||
// if (addReadOnlyConn) {
|
||||
// readOnlyConnection = mariadb.createPool({
|
||||
// host: process.env.DSQL_DB_HOST,
|
||||
// user: process.env.DSQL_DB_READ_ONLY_USERNAME,
|
||||
// password: process.env.DSQL_DB_READ_ONLY_PASSWORD,
|
||||
// database: process.env.DSQL_DB_NAME,
|
||||
// charset: "utf8mb4",
|
||||
// ...readOnlyDbConfig,
|
||||
// ssl: ssl ? grabDbSSL() : undefined,
|
||||
// connectionLimit,
|
||||
// });
|
||||
|
||||
// global.DSQL_READ_ONLY_DB_CONN = readOnlyConnection;
|
||||
// }
|
||||
|
||||
return {
|
||||
conn,
|
||||
// readOnlyConnection,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user