Simple autoreload for wsgi python apps running in uWSGI

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:

while true ; do
  find . -name \*.py                  \ # for python
         -newer /path/app.ini         \ # if changed
         -exec touch /path/app.ini \; \ # reload
         -print                         # print
  sleep 2
done

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).

About these ads

5 thoughts on “Simple autoreload for wsgi python apps running in uWSGI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s