Gracefully terminate Rails Application from within

Viewed 1016

I have a Rails 5 application (API) and a postgres DB that run on separate docker containers, all on the same AWS EC2 instance, and are controlled by an external manager (manage). manage needs to be able to make a request to the API and tell it to exit. I don't want to just kill the API externally or the docker container, as I want all API requests to complete. I want the API to exit gracefully and only it knows how to do that.
Ruby has exit, exit! and abort. All of them seem to be handled by Rails as exceptions and Rails just continues motoring on.

How can I terminate my rails application from within? Is there some sort of unhandleable exception that I can raise?

1 Answers
Related