How to setup auto-reload uwsgi application in django dev environment

If we want to create django project with uwsgi, it is convenient to let uwsgi workers auto reload if there are some changes happens. Basically, we just need monitor the changes of *.py files in the project dir. For apache+mod_wsgi development environment, there is a monitor.py which called in wsgi.py can achieve the same target, but it looks like this method doesn’t works well in nginx+uwsgi development, e,g: graceful reload of uwsgi workers could be affected when WSGI application executes monitor.py thread.

Below method use inotify mechanism to monitor the project file(.py) changes under project dir, and update project dir to tell uwsgi service it need to restart workers.

$ sudo pip install pyinotify

Add option ‘touch-reload’ in uwsgi specific config file to monitor which file/dir changes can cause uwsgi restart workers, e,g:

project_home = /path/to/project
touch-reload= %(project_home)

Download uwsgi-monitory.py script in django project directory, and run it with below syntax:

$ python uwsgi-monitor.py [/path/to/project]

Or if uwsgi specific config file could be found in this project dir:

$ python uwsgi-monitor.py
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇