File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,10 @@ config.DB_TYPE = /** @type {nb.DBType} */ (process.env.DB_TYPE || 'postgres');
251251config . POSTGRES_DEFAULT_MAX_CLIENTS = 10 ;
252252config . POSTGRES_MD_MAX_CLIENTS = ( process . env . LOCAL_MD_SERVER === 'true' ) ? 70 : 10 ;
253253
254+ //whether to use read-only postgres replica cluster
255+ //ro host is set by operator in process.env.POSTGRES_HOST_RO
256+ config . POSTGRES_USE_READ_ONLY = true ;
257+
254258///////////////////
255259// SYSTEM CONFIG //
256260///////////////////
Original file line number Diff line number Diff line change @@ -1525,7 +1525,11 @@ class PostgresClient extends EventEmitter {
15251525 // get the connection configuration. first from env, then from file, then default
15261526 const host = process . env . POSTGRES_HOST || fs_utils . try_read_file_sync ( process . env . POSTGRES_HOST_PATH ) || '127.0.0.1' ;
15271527 //optional read-only host. if not present defaults to general pg host
1528- const host_ro = process . env . POSTGRES_HOST_RO || fs_utils . try_read_file_sync ( process . env . POSTGRES_HOST_RO_PATH ) || host ;
1528+ let host_ro = process . env . POSTGRES_HOST_RO || fs_utils . try_read_file_sync ( process . env . POSTGRES_HOST_RO_PATH ) || host ;
1529+ //if POSTGRES_USE_READ_ONLY is off, switch to regular host
1530+ if ( ! config . POSTGRES_USE_READ_ONLY ) {
1531+ host_ro = host ;
1532+ }
15291533 const user = process . env . POSTGRES_USER || fs_utils . try_read_file_sync ( process . env . POSTGRES_USER_PATH ) || 'postgres' ;
15301534 const password = process . env . POSTGRES_PASSWORD || fs_utils . try_read_file_sync ( process . env . POSTGRES_PASSWORD_PATH ) || 'noobaa' ;
15311535 const database = process . env . POSTGRES_DBNAME || fs_utils . try_read_file_sync ( process . env . POSTGRES_DBNAME_PATH ) || 'nbcore' ;
You can’t perform that action at this time.
0 commit comments