From 51bd5dc21fa42aa4bac5329ea70581834e1a04b9 Mon Sep 17 00:00:00 2001 From: Jeroen van Ingen Date: Mon, 5 Feb 2018 18:19:56 +0100 Subject: [PATCH] Be more liberal and extendable in accepting psql options --- lib/App/Netdisco/Worker/Plugin/Psql.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/App/Netdisco/Worker/Plugin/Psql.pm b/lib/App/Netdisco/Worker/Plugin/Psql.pm index df6e455f..e7aa1a86 100644 --- a/lib/App/Netdisco/Worker/Plugin/Psql.pm +++ b/lib/App/Netdisco/Worker/Plugin/Psql.pm @@ -14,9 +14,18 @@ register_worker({ phase => 'main' }, sub { my $pass = setting('database')->{pass}; my $portnum = undef; - if ($host and $host =~ m/([^;]+);port=(\d+)/) { + if ($host and $host =~ m/([^;]+);(.+)/) { $host = $1; - $portnum = $2; + my $extra = $2; + my @opts = split(/;/, $extra); + debug sprintf("Host: %s, extra: %s\n", $host, $extra); + foreach my $opt (@opts) { + if ($opt =~ m/port=(\d+)/) { + $portnum = $1; + } else { + # Unhandled connection option, ignore for now + } + } } $ENV{PGHOST} = $host if $host;