michelmartin...@yahoo.com Le mardi 13 octobre 2020 à 19:27:45 UTC+2, Nacho B a écrit :
> It does not solve my original problem, but I going to use your tip right > now, because that "potential issue"... is more "usual" than "potential". > > Thank you for your help, Mike: > > Nacho B. > > > El domingo, 11 de octubre de 2020 a las 16:15:44 UTC+2, mikel...@gmail.com > escribió: > >> One more thing. As I said, I only ping the DB when I startup to make >> sure the config is right. It fixes the potential issue of a config error >> pointing the app at a non-existent dev database in production. >> >> In the code, I do this: >> $data = $db->query($query, $retval_ref->{'most_recent_rcd'})->array or >> $log->logdie; >> >> On Sun, Oct 11, 2020 at 5:03 AM Nacho B <jib...@gmail.com> wrote: >> >>> Thank you, MIkel, >>> >>> So, this ping test must be executed for each database access? >>> >>> I know pings are almost nothing, but adding a new non blocking loop... >>> isn't it an overhead all over the application? >>> >>> I wonder why this so common scenario can't be managed inside the wait >>> loop. Maybe there is something I still do not understand in the >>> non-blocking way of life. >>> >>> >>> Regards, >>> Nacho B. >>> >>> >>> El jueves, 8 de octubre de 2020 a las 16:49:02 UTC+2, mikel...@gmail.com >>> escribió: >>> >>>> I do something like this in the MojoMySQL.pm plugin >>>> ------- >>>> >>>> $MOJOMYSQL = Mojo::mysql->new($URL); >>>> >>>> # See if the damned thing is up. >>>> # since we're in ::startup, we don't have the config plugin >>>> available >>>> # ( we pass the config filename in as "app_config" ) >>>> my $config = eval qx{cat $conf->{'app_config'}} >>>> or $log->logdie("Couldn't read config file: " . >>>> $conf->{'app_config'}); >>>> >>>> eval { >>>> local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n >>>> required >>>> alarm $config->{'db_ping_timeout'}; >>>> my $ok = $MOJOMYSQL->db->ping(); >>>> alarm 0; >>>> }; >>>> >>>> if ($@) { >>>> $log->logdie($@) unless $@ eq "alarm\n"; # propagate >>>> unexpected errors >>>> # timed out >>>> my $msg = qq{DB PING FAILED! (continued below)\n} >>>> . qq{**** It seems that >>>> $conf->{'db'} on $conf->{'host'} is down! ****\n} >>>> . qq{**** app runtime env >>>> is: $config->{'environment'} ****\n} >>>> . qq{**** Verify correct >>>> setting in $conf->{'app_config'} ****\n}; >>>> >>>> $log->logdie($msg); >>>> } >>>> else { >>>> # didn't >>>> $log->debug("DB PING: $conf->{'db'} is up"); >>>> return $MOJOMYSQL; >>>> }; >>>> >>>> } # sub mojomysql >>>> >>>> On Thu, Oct 8, 2020 at 2:44 AM Nacho B <jib...@gmail.com> wrote: >>>> >>>>> Hi, I am using Mojo::Pg promises with db queries, and everything is >>>>> great. >>>>> >>>>> But I do not how to manage the case in which database server is down >>>>> and no response is arriving. >>>>> >>>>> I presume that I should insert a timeout somewhere, in the promise, >>>>> but I do not know how. >>>>> >>>>> >>>>> Nacho B. >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Mojolicious" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to mojolicious...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/mojolicious/0b90c0f5-3cb7-4647-8f5e-c1413b713725n%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/mojolicious/0b90c0f5-3cb7-4647-8f5e-c1413b713725n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Mojolicious" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to mojolicious...@googlegroups.com. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/mojolicious/162ac6be-f54f-466d-a1b8-276c2344e4fdn%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/mojolicious/162ac6be-f54f-466d-a1b8-276c2344e4fdn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/12676ac5-05b9-415a-bece-defd71e52145n%40googlegroups.com.