Cleanup MySQL unix socket code and add to sample config

This commit is contained in:
wiz 2022-03-14 13:11:04 +00:00
parent 465529b03f
commit 2023d36603
No known key found for this signature in database
GPG Key ID: A394E332255A6173
3 changed files with 8 additions and 6 deletions

View File

@ -44,6 +44,7 @@
"ENABLED": true, "ENABLED": true,
"HOST": "127.0.0.1", "HOST": "127.0.0.1",
"PORT": 3306, "PORT": 3306,
"SOCKET": "/var/run/mysql/mysql.sock",
"DATABASE": "mempool", "DATABASE": "mempool",
"USERNAME": "mempool", "USERNAME": "mempool",
"PASSWORD": "mempool" "PASSWORD": "mempool"

View File

@ -43,7 +43,7 @@ interface IConfig {
DATABASE: { DATABASE: {
ENABLED: boolean; ENABLED: boolean;
HOST: string, HOST: string,
SOCKET: string | undefined, SOCKET: string,
PORT: number; PORT: number;
DATABASE: string; DATABASE: string;
USERNAME: string; USERNAME: string;
@ -122,7 +122,7 @@ const defaults: IConfig = {
'DATABASE': { 'DATABASE': {
'ENABLED': true, 'ENABLED': true,
'HOST': '127.0.0.1', 'HOST': '127.0.0.1',
'SOCKET': undefined, 'SOCKET': '',
'PORT': 3306, 'PORT': 3306,
'DATABASE': 'mempool', 'DATABASE': 'mempool',
'USERNAME': 'mempool', 'USERNAME': 'mempool',

View File

@ -15,10 +15,11 @@ export class DB {
timezone: '+00:00', timezone: '+00:00',
} }
if (config.DATABASE.SOCKET && config.DATABASE.SOCKET != "") if (config.DATABASE.SOCKET !== "") {
poolConfig.socketPath = config.DATABASE.SOCKET poolConfig.socketPath = config.DATABASE.SOCKET;
else } else {
poolConfig.host = config.DATABASE.HOST poolConfig.host = config.DATABASE.HOST;
}
return poolConfig; return poolConfig;
} }