From 73119f96aa54563efb34cd645e340d9dabcec219 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Mon, 9 May 2016 09:47:32 +0200 Subject: [PATCH] Set application_name to node name in primary_conninfo It will make it simplier to identify node the in pg_stat_replication view --- patroni/postgresql.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index e771bcfb..c8b7a8a9 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -450,10 +450,11 @@ class Postgresql(object): with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f: f.write('\n{}\n'.format('\n'.join(self.config.get('pg_hba', [])))) - @staticmethod - def primary_conninfo(leader_url): + def primary_conninfo(self, leader_url): r = parseurl(leader_url) - return 'user={user} password={password} host={host} port={port} sslmode=prefer sslcompression=1'.format(**r) + r.update({'application_name': self.name, 'sslmode': 'prefer', 'sslcompression': '1'}) + keywords = 'user password host port sslmode sslcompression application_name'.split() + return ' '.join('{0}={{{0}}}'.format(kw) for kw in keywords).format(**r) def check_recovery_conf(self, leader): if not os.path.isfile(self.recovery_conf):