Is there a way to safely restart mod_wsgi processes on demand, possibly running on multiple machines? I'm serving a django app with mod_wsgi
in daemon mode with apache:
WSGIDaemonProcess myapp user=user group=user processes=30 threads=1
WSGIProcessGroup myapp
I read the suggestions in the mod_wsgi
documentation but none of the suggested solutions works for me:
- Running a monitoring script is not recommended in a production system.
- Sending kill signals is not safe in my case. I want to avoid interrupting running requests. The reload must not bring the service down. Slowing down is fine.
- Touching the
mod_wsgi
configuration file does the trick safely, but how to do it on multiple machines?
Ideally we should be able to restart the processes with one action. Any suggestions?
Note: I have to run multiple processes with one thread. My application is not thread safe.
Edit, I can do it from Puppet if that is the only option I have. but I prefer if there a way to do it from a special protected view. I think this is trivial to do on one machine but not multiple ones
Thanks a lot
Best Answer
This would be solved by using a shared codebase such as from an NFS mount.
Alternatively it should be part of your version control / deployment process.
Do you use version control currently?
If so, create a process that ensures the file is updated. You could automate it with a post-commit hook for example.
How do you deploy your code?
Consider using something like Capistrano or Puppet and include an action in your deployment recipe to update that file.