Monitoring and re-establishing a PostgreSQL connection
What follows is just my subjective opinion; you can disagree.


Robust code is maintainable.  You need to be able to change this code if you find a bug in it, or if the requirements change. It might even be that someone else may need to maintain this code.  So you should probably use a regular indenting pattern (2 spaces is normal for Ruby). That would make it a lot easier to see what was going on.  
Likewise, your code would be cleaner if it was split into separate functions. Making the contents of the thread.new block a separate function would be a good place to start, but you could (and maybe should) go further than that.  
It seems to me that the sleep ... retry at the end of the first rescue block are redundant, since you are going to loop around again anyway. YMMV.