Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Mojolicious and connection to a database

by trippledubs (Deacon)
on May 03, 2019 at 08:16 UTC ( #1233316=note: print w/replies, xml ) Need Help??

in reply to Mojolicious and connection to a database

looks great. Conditionally loading a config. Might be able to make it more resilient by making sure what you think is there, like "/inc/script/my_lib.conf". You are checking $ENV{PAR_TEMP} to see if it's set, but not checking to see if it's set correctly. Is the file there? Does it have all the data you need? Does it bomb out correctly when somethings wrong? Assume that something will go wrong, now how long is it going to take to find out why with the default error messages?

Break it imaginatively and just kinda see what happens.

  • Comment on Re: Mojolicious and connection to a database

Replies are listed 'Best First'.
Re^2: Mojolicious and connection to a database
by frazap (Monk) on May 03, 2019 at 09:02 UTC

    Well, loading the config file that way is to make sure the app works when packed with pp. It's no big deal once it's tested.

    My question was more in relation with remembering the connection done using the hash.

    Could the connection be broken by the database server when the page has been load ? If yes, can I check this rather then using the hash value ?

    Thanks for helping anyway !

      What if your database server crashes/shuts down/restarts after you run the plugin() to connect to it? %connections flag will not tell you that. In general, one can ping() prior to, or eval() on each db operation and catch the error if any. So perhaps convert this flag to a sub which pings the db-handle you think you have and return the result. See check if DBI is still connected.

      hmm.. maybe try testing by putting a load on the web server and see how many connections you have to the database? I would think if that part is not working right you would see either increasing number of connections to the database up to some ceiling or your pages not getting data from the database. If I understand your concern correctly.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1233316]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2020-10-26 08:08 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (250 votes). Check out past polls.