Backport #1988: When the postgresql database is restarted, the application is not usable anymore
Architecture - Refactoring
See #1988 for description.
Merge branch 'branches/rudder/2.4'
Fixes #2400 : displays only 5 technical log per page when displaying in a popup
Refs #2398 : add comment to help the future me understand better
Issue #2398: refactoring to factor out condition test on expected reports
Fixes #2444: backport fix for #1988: make postgres connection be check for death before being used