NOTE This answer addresses nginx or Rack setups, as it was written before edits to the original question made it clear that was looking for an answer specific to Heroku. The accepted answer is best for Heroku apps.
When you say "in your app" do you really mean in your app?
Because typically the solution is to drop a maintenance file in your web root. If the file is found, it is served with a 503 Service Not Available
immediately. The request never even makes it to your app, which is presumably "down for maintenance".
In nginx, something like this:
location / {
if (-f $document_root/maintenance.html) {
return 503;
}
# continued server directives
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
It wouldn't really require a push per se, but perhaps a simple rake task or something to add/remove that maintenance file from your app. You could probably also replace any given filename in the -f
check, and simply touch
an empty arbitrary maintenance.whatever
file in your web root, which would then direct nginx to serve the mainenance.html
.
If you don't want to (or can't) mess around with the server config, this very simple Rack middleware does essentially the same thing: https://github.com/ddollar/rack-maintenance