@@ -475,7 +475,6 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
475
475
"""
476
476
477
477
postgres_conf = os .path .join (self .data_dir , "postgresql.conf" )
478
- hba_conf = os .path .join (self .data_dir , "pg_hba.conf" )
479
478
480
479
# We don't have to reinit it if data directory exists
481
480
if os .path .isfile (postgres_conf ):
@@ -485,6 +484,26 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
485
484
initdb_log = os .path .join (self .logs_dir , "initdb.log" )
486
485
_cached_initdb (self .data_dir , initdb_log , initdb_params )
487
486
487
+ # initialize default config files
488
+ self .default_conf (fsync = fsync )
489
+
490
+ return self
491
+
492
+ def default_conf (self , allow_streaming = True , fsync = False ):
493
+ """
494
+ Apply default settings to this node.
495
+
496
+ Args:
497
+ allow_streaming: should this node add a hba entry for replication?
498
+ fsync: should this node use fsync to keep data safe?
499
+
500
+ Returns:
501
+ This instance of PostgresNode.
502
+ """
503
+
504
+ postgres_conf = os .path .join (self .data_dir , "postgresql.conf" )
505
+ hba_conf = os .path .join (self .data_dir , "pg_hba.conf" )
506
+
488
507
# add parameters to hba file
489
508
with open (hba_conf , "w" ) as conf :
490
509
conf .write ("# TYPE\t DATABASE\t USER\t ADDRESS\t \t METHOD\n "
@@ -502,9 +521,9 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
502
521
conf .write ("fsync = off\n " )
503
522
504
523
conf .write ("log_statement = all\n "
505
- "port = {} \n " . format ( self . port ))
506
-
507
- conf . write ( "listen_addresses = '{}' \n " . format ( self .host ))
524
+ "listen_addresses = '{}' \n "
525
+ "port = {} \n " . format ( self . host ,
526
+ self .port ))
508
527
509
528
if allow_streaming :
510
529
cur_ver = LooseVersion (get_pg_config ()["VERSION_NUM" ])
@@ -516,7 +535,6 @@ def init(self, allow_streaming=False, fsync=False, initdb_params=[]):
516
535
conf .write ("max_wal_senders = 5\n "
517
536
"wal_keep_segments = 20\n "
518
537
"hot_standby = on\n "
519
- "max_connections = 10\n "
520
538
"wal_level = {}\n " .format (wal_level ))
521
539
522
540
return self
0 commit comments