Handle db fail

How can I handle the situation when the primary db instance is turned off and it is time to switch to read only replica to deliver at least this experience.