Hi,
I have an issue with a Mojolicious app that seems to loose connection to a Postgres database whenever the postgres service is restarted. Is this normal behavior, shouldn't the Mojo app automatically reconnect without having to restart hypnotoad?
The error that gets logged is:
[error] no connection to the server at /var/www/mojoApp...
Postgres db connection:
app->attr(db => sub {
my $self = shift;
my $dbh = &connect('dbname');
return $dbh;
});
connect sub:
my ($dbname) = shift;
if($dbname && $dbname ne '')
{
my $host='xx.xx.xx.xx';
my $dsn=qq(dbi:Pg:dbname=$dbname;host=$host);
my $dbusername = xx;
my $password = xx;
my $dbh = DBI->connect($dsn,$dbusername,$password)|| die("Connect error: $DBI::errstr");
return $dbh;
}
Is there something else that I need to add?
Thanks