Hello! I created this gist to demonstrate how you can handle Heroku dyno restarts in Django. This is based off of this stackoverflow question. Many thanks to the writer of the awnser. To put activate the Middleware, you must put this in your django settings file:
MIDDLEWARE_CLASSES = (
'Middleware.ShutdownMiddleware',
# All the prexisting classes
...
)
You should probably put this at the top so you can return the 500 error instantly, but if you have something like SSLify you may want to put that at the top, but it puts a small barrier between you and the instant server-wide 500 error. That's it!
Thanks to everybody mentioned on the stackoverflow question, including the OP.
Bye! ~CrazyPython