Auto reboot with uwsgi and nginx code modification
By default, uwsgi itself does not load modified files immediately.
For sites deployed with nginx + uwsgi + django, if you change the py code, you need to restart uwsgi for it to take effect.
If you need Django code changes to take effect immediately, you can add the parameter py-autoreload = 1 to the configuration file of the ini that starts uwsgi (write it in the ini configuration file, and remember that it must be = 1, or it won't take effect).
py-autoreload = 1
Full Configuration
[uwsgi] socket = 127.0.0.1:9090 stats = 127.0.0.1:9191 chdir = /var/project/feiublog wsgi-file =/var/project/feiublog/ pidfile = /var/project/feiublog/uwsgi_blog.pid touch-reload = /var/project/feiublog/uwsgi_blog.pid buffer-size = 32768 processes = 1 workers= 2 threads = 2 daemonize = /tmp/log/uwsgi_blog.log py-autoreload = 1 # Automatic reboot after code change
The correct way to manually reload uwsgi and code
Use the command uwsgi to automatically generate the pidfile file uswgi_blog.pid.
pidfile = /var/project/feiublog/uwsgi_blog.pid
Then execute it in your directory:
uwsgi --reload uwsgi_blog.pid
Where uwsgi_blog.pid is the process pid file.
At this point, the modified code can be automatically reloaded to take effect
Django modified file does not take effect after restarting uwsgi to solve the problem
Description of the problem
The main thing here is that in the online environment, we uploaded the code and found that it didn't take effect.
Because .pyc files are generated.
method settle an issue
# Shut down all uwsgi processes, found that passing uwsgi --roload ****.pid didn't always work killall -9 uwsgi # Start uwsgi uwsgi --ini /home/wwwroot// # Restart nginx service nginx reload
summarize
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.