From 8ac648a9a0d7bf9f2df03ec8fc952d088fe0d740 Mon Sep 17 00:00:00 2001 From: Rogan Hamby Date: Tue, 20 Mar 2018 12:20:25 -0400 Subject: [PATCH] some failover to connect directly by socket if full TCP settings aren't found --- mig-bin/Mig.pm | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mig-bin/Mig.pm b/mig-bin/Mig.pm index 46aa1d1..f1b97f2 100644 --- a/mig-bin/Mig.pm +++ b/mig-bin/Mig.pm @@ -19,14 +19,20 @@ use Env qw( ); sub db_connect { - my $dbh = DBI->connect( + my $dbh; + if ($PGHOST) { + $dbh = DBI->connect( "dbi:Pg:host=$PGHOST;dbname=$PGDATABASE;port=$PGPORT" ,$PGUSER ,undef - ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + ) || die "Unable to connect to $PGHOST:$PGPORT:$PGDATABASE:$PGUSER : $!\n"; + } else { + $dbh = DBI->connect("dbi:Pg:dbname=$PGDATABASE", "", "") || die "Unable to connect to $PGDATABASE : $!\n"; + } $dbh->do("SET search_path TO $MIGSCHEMA, evergreen, pg_catalog, public"); return $dbh; } + sub db_disconnect { my $dbh = shift; $dbh->disconnect; -- 1.7.2.5