Detect rails server shutdown

309 Views Asked by At

How to detect any Rails server shutdown from within Rails application? I am looking for a solution which may work with WEBrick, Puma, Unicorn, Passenger.

What I want to do on server shutdown is to send message through WebSockets and set terminate flag to Web Sockets server to make it shut down properly.

1

There are 1 best solutions below

1
On

You should run secondary rails app on another server sharing same database. And you need to send ajax request regularly to the main app to check termination, and you can send ajax request to secondary app when main app is terminated and send email or whatever.