Question: We have certain sysadmin settings that we expose to superusers of our django webapp. Things like the domain name (uses contrib.sites) and single sign-on configuration. Some of these settings are cached by the system, sometimes because we want to avoid an extra DB hit in the middleware on every request if we can help it, sometimes because it's contrib.sites, which has its own caching. So when the settings get changed, the changes don't take effect until the app is reloaded.

We want the app to restart itself when these changes are made, so that our clients don't need to pester us to do the restart for them.

Our webapp is running on apache via mod\_wsgi, so we should be able to do this just by touching the wsgi file for the app whenever one of these settings is changed, but it feels a little weird to do that, and I'm worried there's some more graceful convention we should be following.

Is there a right way to apply updates that are cached and require the app to reload? Invalidating the caches for these things will be pretty hairy, so I think I'd avoid that unless the app restart thing has serious drawbacks.

Answer: 
If you use WSGI and your process is being watched by a controller like supervisord, gunicorn, uwsgi or similar then you can simply send yourself a SIGINT or SIGQUIT (depending on controller). It should shut down the current process gracefully and the controller will restart it for you.

```
import signal, os
os.kill(os.getpid(), signal.SIGQUIT)

```
If you are running it on apache with mod\_wsgi, just update the timestamp of wsgi config file everytime you make change to a model. Apache automatically restarts the application if the wsgi file gets updated.