Simple autoreload for wsgi python apps running in uWSGI

Mar 06, 2013

While developing, it's usefull to have uwsgi autoreload your application. In my case I rsync changed files to the server running uWSGI. But uWSGI only monitors the app configuration file, which generally doesn't change. In order to have your app auto-reload (like django does) you can switch to your app's base directory and execute:
[sourcecode language="bash"]
while true ; do
find . -name \*.py \ # for python
-newer /path/app.ini \ # if changed
-exec touch /path/app.ini \; \ # reload
-print # print
sleep 2

Everytime you rsync or scp some python file to the server the -newer predicate will turn true for this file and find will touch the configuration file (thereby making it newer than all the source files).