@ -76,7 +76,7 @@ export class ConfigService {
}
}
]
]
} ;
} ;
if ( + process . env . RTL_SSO === 0 || configData . SSO . rtlSSO === 0 ) {
if ( ( process ? . env ? . RTL_SSO && + process ? . env ? . RTL_SSO === 0 ) || configData . SSO . rtlSSO === 0 ) {
configData [ 'multiPass' ] = 'password' ;
configData [ 'multiPass' ] = 'password' ;
}
}
return configData ;
return configData ;
@ -95,7 +95,7 @@ export class ConfigService {
private updateLogByLevel = ( ) = > {
private updateLogByLevel = ( ) = > {
let updateLogFlag = false ;
let updateLogFlag = false ;
this . common . rtl_conf_file_path = process . env . RTL_CONFIG_PATH ? process .env.RTL_CONFIG_PATH : join ( this . directoryName , '../..' ) ;
this . common . rtl_conf_file_path = process ? . env ? . RTL_CONFIG_PATH ? process ? .env? .RTL_CONFIG_PATH : join ( this . directoryName , '../..' ) ;
try {
try {
const RTLConfFile = this . common . rtl_conf_file_path + sep + 'RTL-Config.json' ;
const RTLConfFile = this . common . rtl_conf_file_path + sep + 'RTL-Config.json' ;
const config = JSON . parse ( fs . readFileSync ( RTLConfFile , 'utf-8' ) ) ;
const config = JSON . parse ( fs . readFileSync ( RTLConfFile , 'utf-8' ) ) ;
@ -115,9 +115,9 @@ export class ConfigService {
} ;
} ;
private validateNodeConfig = ( config ) = > {
private validateNodeConfig = ( config ) = > {
if ( ( + process . env . RTL_SSO === 0 ) || ( typeof process . env . RTL_SSO === 'undefined' && + config . SSO . rtlSSO === 0 ) ) {
if ( ( process ? . env ? . RTL_SSO && + process ? . env ? . RTL_SSO === 0 ) || ( typeof process ? . env ? . RTL_SSO === 'undefined' && + config . SSO . rtlSSO === 0 ) ) {
if ( process . env . APP_PASSWORD && process . env . APP_PASSWORD . trim ( ) !== '' ) {
if ( process ? . env ? . APP_PASSWORD && process ? . env ? . APP_PASSWORD . trim ( ) !== '' ) {
this . common . rtl_pass = this . hash . update ( process . env . APP_PASSWORD ) . digest ( 'hex' ) ;
this . common . rtl_pass = this . hash . update ( process ? . env ? . APP_PASSWORD ) . digest ( 'hex' ) ;
this . common . flg_allow_password_update = false ;
this . common . flg_allow_password_update = false ;
} else if ( config . multiPassHashed && config . multiPassHashed !== '' ) {
} else if ( config . multiPassHashed && config . multiPassHashed !== '' ) {
this . common . rtl_pass = config . multiPassHashed ;
this . common . rtl_pass = config . multiPassHashed ;
@ -128,21 +128,21 @@ export class ConfigService {
}
}
this . common . rtl_secret2fa = config . secret2fa ;
this . common . rtl_secret2fa = config . secret2fa ;
} else {
} else {
if ( process . env . APP_PASSWORD && process . env . APP_PASSWORD . trim ( ) !== '' ) {
if ( process ? . env ? . APP_PASSWORD && process ? . env ? . APP_PASSWORD . trim ( ) !== '' ) {
this . errMsg = this . errMsg + '\nRTL Password cannot be set with SSO. Please set SSO as 0 or remove password.' ;
this . errMsg = this . errMsg + '\nRTL Password cannot be set with SSO. Please set SSO as 0 or remove password.' ;
}
}
}
}
this . common . port = ( process . env . PORT ) ? this . normalizePort ( process . env . PORT ) : ( config . port ) ? this . normalizePort ( config . port ) : 3000 ;
this . common . port = ( process ? . env ? . PORT ) ? this . normalizePort ( process ? . env ? . PORT ) : ( config . port ) ? this . normalizePort ( config . port ) : 3000 ;
this . common . host = ( process . env . HOST ) ? process . env . HOST : ( config . host ) ? config.host : null ;
this . common . host = ( process ? . env ? . HOST ) ? process ? . env ? . HOST : ( config . host ) ? config.host : null ;
if ( config . nodes && config . nodes . length > 0 ) {
if ( config . nodes && config . nodes . length > 0 ) {
config . nodes . forEach ( ( node , idx ) = > {
config . nodes . forEach ( ( node , idx ) = > {
this . common . nodes [ idx ] = { } ;
this . common . nodes [ idx ] = { } ;
this . common . nodes [ idx ] . index = node . index ;
this . common . nodes [ idx ] . index = node . index ;
this . common . nodes [ idx ] . ln_node = node . lnNode ;
this . common . nodes [ idx ] . ln_node = node . lnNode ;
this . common . nodes [ idx ] . ln_implementation = ( process . env . LN_IMPLEMENTATION ) ? process .env.LN_IMPLEMENTATION : node.lnImplementation ? node . lnImplementation : 'LND' ;
this . common . nodes [ idx ] . ln_implementation = ( process ? . env ? . LN_IMPLEMENTATION ) ? process ? .env? .LN_IMPLEMENTATION : node.lnImplementation ? node . lnImplementation : 'LND' ;
if ( this . common . nodes [ idx ] . ln_implementation === 'CLT' ) { this . common . nodes [ idx ] . ln_implementation = 'CLN' ; }
if ( this . common . nodes [ idx ] . ln_implementation === 'CLT' ) { this . common . nodes [ idx ] . ln_implementation = 'CLN' ; }
if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' && process . env . MACAROON_PATH && process . env . MACAROON_PATH . trim ( ) !== '' ) {
if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' && process ? . env ? . MACAROON_PATH && process ? . env ? . MACAROON_PATH . trim ( ) !== '' ) {
this . common . nodes [ idx ] . macaroon_path = process . env . MACAROON_PATH ;
this . common . nodes [ idx ] . macaroon_path = process ? . env ? . MACAROON_PATH ;
} else if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' && node . Authentication && node . Authentication . macaroonPath && node . Authentication . macaroonPath . trim ( ) !== '' ) {
} else if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' && node . Authentication && node . Authentication . macaroonPath && node . Authentication . macaroonPath . trim ( ) !== '' ) {
this . common . nodes [ idx ] . macaroon_path = node . Authentication . macaroonPath ;
this . common . nodes [ idx ] . macaroon_path = node . Authentication . macaroonPath ;
} else if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' ) {
} else if ( this . common . nodes [ idx ] . ln_implementation !== 'ECL' ) {
@ -150,16 +150,16 @@ export class ConfigService {
}
}
if ( this . common . nodes [ idx ] . ln_implementation === 'ECL' ) {
if ( this . common . nodes [ idx ] . ln_implementation === 'ECL' ) {
if ( process . env . LN_API_PASSWORD ) {
if ( process ? . env ? . LN_API_PASSWORD ) {
this . common . nodes [ idx ] . ln_api_password = process . env . LN_API_PASSWORD ;
this . common . nodes [ idx ] . ln_api_password = process ? . env ? . LN_API_PASSWORD ;
} else if ( node . Authentication && node . Authentication . lnApiPassword ) {
} else if ( node . Authentication && node . Authentication . lnApiPassword ) {
this . common . nodes [ idx ] . ln_api_password = node . Authentication . lnApiPassword ;
this . common . nodes [ idx ] . ln_api_password = node . Authentication . lnApiPassword ;
} else {
} else {
this . common . nodes [ idx ] . ln_api_password = '' ;
this . common . nodes [ idx ] . ln_api_password = '' ;
}
}
}
}
if ( process . env . CONFIG_PATH ) {
if ( process ? . env ? . CONFIG_PATH ) {
this . common . nodes [ idx ] . config_path = process . env . CONFIG_PATH ;
this . common . nodes [ idx ] . config_path = process ? . env ? . CONFIG_PATH ;
} else if ( node . Authentication && node . Authentication . configPath ) {
} else if ( node . Authentication && node . Authentication . configPath ) {
this . common . nodes [ idx ] . config_path = node . Authentication . configPath ;
this . common . nodes [ idx ] . config_path = node . Authentication . configPath ;
} else {
} else {
@ -167,10 +167,10 @@ export class ConfigService {
}
}
if ( this . common . nodes [ idx ] . ln_implementation === 'ECL' && this . common . nodes [ idx ] . ln_api_password === '' && this . common . nodes [ idx ] . config_path !== '' ) {
if ( this . common . nodes [ idx ] . ln_implementation === 'ECL' && this . common . nodes [ idx ] . ln_api_password === '' && this . common . nodes [ idx ] . config_path !== '' ) {
try {
try {
const exists = fs . existsSync ( this . common . nodes [ idx ] . config_path ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . config_path || '' ) ;
if ( exists ) {
if ( exists ) {
try {
try {
const configFile = fs . readFileSync ( this . common . nodes [ idx ] . config_path , 'utf-8' ) ;
const configFile = fs . readFileSync ( ( this . common . nodes [ idx ] . config_path || '' ) , 'utf-8' ) ;
const iniParsed = ini . parse ( configFile ) ;
const iniParsed = ini . parse ( configFile ) ;
this . common . nodes [ idx ] . ln_api_password = iniParsed [ 'eclair.api.password' ] ? iniParsed [ 'eclair.api.password' ] : parseHocon ( configFile ) . eclair . api . password ;
this . common . nodes [ idx ] . ln_api_password = iniParsed [ 'eclair.api.password' ] ? iniParsed [ 'eclair.api.password' ] : parseHocon ( configFile ) . eclair . api . password ;
} catch ( err ) {
} catch ( err ) {
@ -187,10 +187,10 @@ export class ConfigService {
this . errMsg = this . errMsg + '\nPlease set config path Or api password for node index ' + node . index + ' in RTL-Config.json! It is mandatory for Eclair authentication!' ;
this . errMsg = this . errMsg + '\nPlease set config path Or api password for node index ' + node . index + ' in RTL-Config.json! It is mandatory for Eclair authentication!' ;
}
}
if ( process . env . LN_SERVER_URL && process . env . LN_SERVER_URL . trim ( ) !== '' ) {
if ( process ? . env ? . LN_SERVER_URL && process ? . env ? . LN_SERVER_URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . ln_server_url = process . env . LN_SERVER_URL . endsWith ( '/v1' ) ? process . env . LN_SERVER_URL . slice ( 0 , - 3 ) : process . env . LN_SERVER_URL ;
this . common . nodes [ idx ] . ln_server_url = process ? . env ? . LN_SERVER_URL . endsWith ( '/v1' ) ? process ? . env ? . LN_SERVER_URL . slice ( 0 , - 3 ) : process ? . env ? . LN_SERVER_URL ;
} else if ( process . env . LND_SERVER_URL && process . env . LND_SERVER_URL . trim ( ) !== '' ) {
} else if ( process ? . env ? . LND_SERVER_URL && process ? . env ? . LND_SERVER_URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . ln_server_url = process . env . LND_SERVER_URL . endsWith ( '/v1' ) ? process . env . LND_SERVER_URL . slice ( 0 , - 3 ) : process . env . LND_SERVER_URL ;
this . common . nodes [ idx ] . ln_server_url = process ? . env ? . LND_SERVER_URL . endsWith ( '/v1' ) ? process ? . env ? . LND_SERVER_URL . slice ( 0 , - 3 ) : process ? . env ? . LND_SERVER_URL ;
} else if ( node . Settings . lnServerUrl && node . Settings . lnServerUrl . trim ( ) !== '' ) {
} else if ( node . Settings . lnServerUrl && node . Settings . lnServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . ln_server_url = node . Settings . lnServerUrl . endsWith ( '/v1' ) ? node . Settings . lnServerUrl . slice ( 0 , - 3 ) : node . Settings . lnServerUrl ;
this . common . nodes [ idx ] . ln_server_url = node . Settings . lnServerUrl . endsWith ( '/v1' ) ? node . Settings . lnServerUrl . slice ( 0 , - 3 ) : node . Settings . lnServerUrl ;
} else if ( node . Settings . lndServerUrl && node . Settings . lndServerUrl . trim ( ) !== '' ) {
} else if ( node . Settings . lndServerUrl && node . Settings . lndServerUrl . trim ( ) !== '' ) {
@ -207,9 +207,9 @@ export class ConfigService {
if ( this . common . nodes [ idx ] . fiat_conversion ) {
if ( this . common . nodes [ idx ] . fiat_conversion ) {
this . common . nodes [ idx ] . currency_unit = node . Settings . currencyUnit ? node . Settings . currencyUnit : 'USD' ;
this . common . nodes [ idx ] . currency_unit = node . Settings . currencyUnit ? node . Settings . currencyUnit : 'USD' ;
}
}
if ( process . env . SWAP_SERVER_URL && process . env . SWAP_SERVER_URL . trim ( ) !== '' ) {
if ( process ? . env ? . SWAP_SERVER_URL && process ? . env ? . SWAP_SERVER_URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . swap_server_url = process . env . SWAP_SERVER_URL . endsWith ( '/v1' ) ? process . env . SWAP_SERVER_URL . slice ( 0 , - 3 ) : process . env . SWAP_SERVER_URL ;
this . common . nodes [ idx ] . swap_server_url = process ? . env ? . SWAP_SERVER_URL . endsWith ( '/v1' ) ? process ? . env ? . SWAP_SERVER_URL . slice ( 0 , - 3 ) : process ? . env ? . SWAP_SERVER_URL ;
this . common . nodes [ idx ] . swap_macaroon_path = process . env . SWAP_MACAROON_PATH ;
this . common . nodes [ idx ] . swap_macaroon_path = process ? . env ? . SWAP_MACAROON_PATH ;
} else if ( node . Settings . swapServerUrl && node . Settings . swapServerUrl . trim ( ) !== '' ) {
} else if ( node . Settings . swapServerUrl && node . Settings . swapServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . swap_server_url = node . Settings . swapServerUrl . endsWith ( '/v1' ) ? node . Settings . swapServerUrl . slice ( 0 , - 3 ) : node . Settings . swapServerUrl ;
this . common . nodes [ idx ] . swap_server_url = node . Settings . swapServerUrl . endsWith ( '/v1' ) ? node . Settings . swapServerUrl . slice ( 0 , - 3 ) : node . Settings . swapServerUrl ;
this . common . nodes [ idx ] . swap_macaroon_path = node . Authentication . swapMacaroonPath ? node . Authentication . swapMacaroonPath : '' ;
this . common . nodes [ idx ] . swap_macaroon_path = node . Authentication . swapMacaroonPath ? node . Authentication . swapMacaroonPath : '' ;
@ -217,9 +217,9 @@ export class ConfigService {
this . common . nodes [ idx ] . swap_server_url = '' ;
this . common . nodes [ idx ] . swap_server_url = '' ;
this . common . nodes [ idx ] . swap_macaroon_path = '' ;
this . common . nodes [ idx ] . swap_macaroon_path = '' ;
}
}
if ( process . env . BOLTZ_SERVER_URL && process . env . BOLTZ_SERVER_URL . trim ( ) !== '' ) {
if ( process ? . env ? . BOLTZ_SERVER_URL && process ? . env ? . BOLTZ_SERVER_URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . boltz_server_url = process . env . BOLTZ_SERVER_URL . endsWith ( '/v1' ) ? process . env . BOLTZ_SERVER_URL . slice ( 0 , - 3 ) : process . env . BOLTZ_SERVER_URL ;
this . common . nodes [ idx ] . boltz_server_url = process ? . env ? . BOLTZ_SERVER_URL . endsWith ( '/v1' ) ? process ? . env ? . BOLTZ_SERVER_URL . slice ( 0 , - 3 ) : process ? . env ? . BOLTZ_SERVER_URL ;
this . common . nodes [ idx ] . boltz_macaroon_path = process . env . BOLTZ_MACAROON_PATH ;
this . common . nodes [ idx ] . boltz_macaroon_path = process ? . env ? . BOLTZ_MACAROON_PATH ;
} else if ( node . Settings . boltzServerUrl && node . Settings . boltzServerUrl . trim ( ) !== '' ) {
} else if ( node . Settings . boltzServerUrl && node . Settings . boltzServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . boltz_server_url = node . Settings . boltzServerUrl . endsWith ( '/v1' ) ? node . Settings . boltzServerUrl . slice ( 0 , - 3 ) : node . Settings . boltzServerUrl ;
this . common . nodes [ idx ] . boltz_server_url = node . Settings . boltzServerUrl . endsWith ( '/v1' ) ? node . Settings . boltzServerUrl . slice ( 0 , - 3 ) : node . Settings . boltzServerUrl ;
this . common . nodes [ idx ] . boltz_macaroon_path = node . Authentication . boltzMacaroonPath ? node . Authentication . boltzMacaroonPath : '' ;
this . common . nodes [ idx ] . boltz_macaroon_path = node . Authentication . boltzMacaroonPath ? node . Authentication . boltzMacaroonPath : '' ;
@ -227,10 +227,10 @@ export class ConfigService {
this . common . nodes [ idx ] . boltz_server_url = '' ;
this . common . nodes [ idx ] . boltz_server_url = '' ;
this . common . nodes [ idx ] . boltz_macaroon_path = '' ;
this . common . nodes [ idx ] . boltz_macaroon_path = '' ;
}
}
this . common . nodes [ idx ] . enable_offers = process . env . ENABLE_OFFERS ? process . env . ENABLE_OFFERS : ( node . Settings . enableOffers ) ? node.Settings.enableOffers : false ;
this . common . nodes [ idx ] . enable_offers = process ? . env ? . ENABLE_OFFERS ? process ? . env ? . ENABLE_OFFERS : ( node . Settings . enableOffers ) ? node.Settings.enableOffers : false ;
this . common . nodes [ idx ] . enable_peerswap = process . env . ENABLE_PEERSWAP ? process . env . ENABLE_PEERSWAP : ( node . Settings . enablePeerswap ) ? node.Settings.enablePeerswap : false ;
this . common . nodes [ idx ] . enable_peerswap = process ? . env ? . ENABLE_PEERSWAP ? process ? . env ? . ENABLE_PEERSWAP : ( node . Settings . enablePeerswap ) ? node.Settings.enablePeerswap : false ;
this . common . nodes [ idx ] . bitcoind_config_path = process . env . BITCOIND_CONFIG_PATH ? process . env . BITCOIND_CONFIG_PATH : ( node . Settings . bitcoindConfigPath ) ? node . Settings . bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . bitcoind_config_path = process ? . env ? . BITCOIND_CONFIG_PATH ? process ? . env ? . BITCOIND_CONFIG_PATH : ( node . Settings . bitcoindConfigPath ) ? node . Settings . bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . channel_backup_path = process . env . CHANNEL_BACKUP_PATH ? process . env . CHANNEL_BACKUP_PATH : ( node . Settings . channelBackupPath ) ? node.Settings.channelBackupPath : this.common.rtl_conf_file_path + sep + 'channels-backup' + sep + 'node-' + node . index ;
this . common . nodes [ idx ] . channel_backup_path = process ? . env ? . CHANNEL_BACKUP_PATH ? process ? . env ? . CHANNEL_BACKUP_PATH : ( node . Settings . channelBackupPath ) ? node.Settings.channelBackupPath : this.common.rtl_conf_file_path + sep + 'channels-backup' + sep + 'node-' + node . index ;
try {
try {
this . common . createDirectory ( this . common . nodes [ idx ] . channel_backup_path ) ;
this . common . createDirectory ( this . common . nodes [ idx ] . channel_backup_path ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . channel_backup_path + sep + 'channel-all.bak' ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . channel_backup_path + sep + 'channel-all.bak' ) ;
@ -252,13 +252,13 @@ export class ConfigService {
this . common . nodes [ idx ] . log_file = this . common . rtl_conf_file_path + '/logs/RTL-Node-' + node . index + '.log' ;
this . common . nodes [ idx ] . log_file = this . common . rtl_conf_file_path + '/logs/RTL-Node-' + node . index + '.log' ;
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'INFO' , fileName : 'Config' , msg : 'Node Config: ' + JSON . stringify ( this . common . nodes [ idx ] ) } ) ;
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'INFO' , fileName : 'Config' , msg : 'Node Config: ' + JSON . stringify ( this . common . nodes [ idx ] ) } ) ;
const log_file = this . common . nodes [ idx ] . log_file ;
const log_file = this . common . nodes [ idx ] . log_file ;
if ( fs . existsSync ( log_file ) ) {
if ( fs . existsSync ( log_file || '' ) ) {
fs . writeFile ( log_file , '' , ( ) = > { } ) ;
fs . writeFile ( ( log_file || '' ) , '' , ( ) = > { } ) ;
} else {
} else {
try {
try {
const directoryName = dirname ( log_file ) ;
const directoryName = dirname ( log_file || '' ) ;
this . common . createDirectory ( directoryName ) ;
this . common . createDirectory ( directoryName ) ;
const createStream = fs . createWriteStream ( log_file ) ;
const createStream = fs . createWriteStream ( log_file || '' ) ;
createStream . end ( ) ;
createStream . end ( ) ;
} catch ( err ) {
} catch ( err ) {
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while creating log file ' + log_file + ': \n' + err } ) ;
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while creating log file ' + log_file + ': \n' + err } ) ;
@ -271,22 +271,22 @@ export class ConfigService {
} ;
} ;
private setSSOParams = ( config ) = > {
private setSSOParams = ( config ) = > {
if ( process . env . RTL_SSO ) {
if ( process ? . env ? . RTL_SSO ) {
this . common . rtl_sso = + process . env . RTL_SSO ;
this . common . rtl_sso = + process ? . env ? . RTL_SSO ;
} else if ( config . SSO && config . SSO . rtlSSO ) {
} else if ( config . SSO && config . SSO . rtlSSO ) {
this . common . rtl_sso = config . SSO . rtlSSO ;
this . common . rtl_sso = config . SSO . rtlSSO ;
}
}
if ( process . env . RTL_COOKIE_PATH ) {
if ( process ? . env ? . RTL_COOKIE_PATH ) {
this . common . rtl_cookie_path = process . env . RTL_COOKIE_PATH ;
this . common . rtl_cookie_path = process ? . env ? . RTL_COOKIE_PATH ;
} else if ( config . SSO && config . SSO . rtlCookiePath ) {
} else if ( config . SSO && config . SSO . rtlCookiePath ) {
this . common . rtl_cookie_path = config . SSO . rtlCookiePath ;
this . common . rtl_cookie_path = config . SSO . rtlCookiePath ;
} else {
} else {
this . common . rtl_cookie_path = '' ;
this . common . rtl_cookie_path = '' ;
}
}
if ( process . env . LOGOUT_REDIRECT_LINK ) {
if ( process ? . env ? . LOGOUT_REDIRECT_LINK ) {
this . common . logout_redirect_link = process . env . LOGOUT_REDIRECT_LINK ;
this . common . logout_redirect_link = process ? . env ? . LOGOUT_REDIRECT_LINK ;
} else if ( config . SSO && config . SSO . logoutRedirectLink ) {
} else if ( config . SSO && config . SSO . logoutRedirectLink ) {
this . common . logout_redirect_link = config . SSO . logoutRedirectLink ;
this . common . logout_redirect_link = config . SSO . logoutRedirectLink ;
}
}
@ -302,15 +302,15 @@ export class ConfigService {
private setSelectedNode = ( config ) = > {
private setSelectedNode = ( config ) = > {
if ( config . defaultNodeIndex ) {
if ( config . defaultNodeIndex ) {
this . common . initSelectedNode = this . common . findNode ( config . defaultNodeIndex ) ;
this . common . initSelectedNode = this . common . findNode ( config . defaultNodeIndex ) || { } ;
} else {
} else {
this . common . initSelectedNode = this . common . findNode ( this . common . nodes [ 0 ] . index ) ;
this . common . initSelectedNode = this . common . findNode ( this . common . nodes [ 0 ] . index ) || { } ;
}
}
} ;
} ;
public setServerConfiguration = ( ) = > {
public setServerConfiguration = ( ) = > {
try {
try {
this . common . rtl_conf_file_path = ( process . env . RTL_CONFIG_PATH ) ? process .env.RTL_CONFIG_PATH : join ( this . directoryName , '../..' ) ;
this . common . rtl_conf_file_path = ( process ? . env ? . RTL_CONFIG_PATH ) ? process ? .env? .RTL_CONFIG_PATH : join ( this . directoryName , '../..' ) ;
const confFileFullPath = this . common . rtl_conf_file_path + sep + 'RTL-Config.json' ;
const confFileFullPath = this . common . rtl_conf_file_path + sep + 'RTL-Config.json' ;
if ( ! fs . existsSync ( confFileFullPath ) ) {
if ( ! fs . existsSync ( confFileFullPath ) ) {
fs . writeFileSync ( confFileFullPath , JSON . stringify ( this . setDefaultConfig ( ) ) ) ;
fs . writeFileSync ( confFileFullPath , JSON . stringify ( this . setDefaultConfig ( ) ) ) ;
@ -319,7 +319,7 @@ export class ConfigService {
this . updateLogByLevel ( ) ;
this . updateLogByLevel ( ) ;
this . validateNodeConfig ( config ) ;
this . validateNodeConfig ( config ) ;
this . setSelectedNode ( config ) ;
this . setSelectedNode ( config ) ;
} catch ( err ) {
} catch ( err : any ) {
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while configuring the node server: \n' + err } ) ;
this . logger . log ( { selectedNode : this.common.initSelectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while configuring the node server: \n' + err } ) ;
throw new Error ( err ) ;
throw new Error ( err ) ;
}
}