Skip to content

Commit

Permalink
Do not fail when there is no postgresql/parameters section in a confi…
Browse files Browse the repository at this point in the history
…g file
  • Loading branch information
Alexander Kukushkin committed Nov 11, 2015
1 parent 87ead9d commit 9c16830
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions patroni/postgresql.py
Expand Up @@ -42,6 +42,7 @@ class Postgresql:
def __init__(self, config):
self.config = config
self.name = config['name']
self.server_parameters = config.get('parameters', {})
self.scope = config['scope']
self.listen_addresses, self.port = config['listen'].split(':')
self.data_dir = config['data_dir']
Expand Down Expand Up @@ -323,7 +324,7 @@ def restart(self):

def server_options(self):
options = "--listen_addresses='{}' --port={}".format(self.listen_addresses, self.port)
for setting, value in self.config['parameters'].items():
for setting, value in self.server_parameters.items():
options += " --{}='{}'".format(setting, value)
return options

Expand All @@ -341,7 +342,7 @@ def write_pg_hba(self):
with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f:
f.write('\nhost replication {username} {network} md5\n'.format(**self.replication))
for line in self.config.get('pg_hba', []):
if line.split()[0].strip() == 'hostssl' and self.config['parameters'].get('ssl', 'off').lower() != 'on':
if line.split()[0].strip() == 'hostssl' and self.server_parameters.get('ssl', 'off').lower() != 'on':
continue
f.write(line + '\n')

Expand Down

0 comments on commit 9c16830

Please sign in to comment.