曦远 (DealiAxy)一份私人的文字刊物

StarBlog
返回文章列表折页手记阅读全文
Django

About the management of the uwsgi server

Foreword It's great to use Django for project development, but the deployment is too troublesome. With the Uwsgi server, every time you modify the code, you need to restart the server for the changes to take effect. Restarting the uwsgi server is also quite cumbersome. After looking at the official documentation, it's best to install uwsgi into the venv virtual environment so that it's easy to distinguish when running `ps aux`. Checking uwsgi processes `ps -aux | grep uwsgi` Terminating the original uwsgi process `kill -9 27543` Conclusion

曦远 (DealiAxy)约 7 分钟
目录6 个章节

Preface

Using Django to develop projects is great, but deployment is quite troublesome. When using the Uwsgi server, every time the code is modified, the server needs to be restarted for the changes to take effect. Moreover, restarting the Uwsgi server is also quite a hassle.

After reviewing the official documentation, it's best to install Uwsgi inside a venv virtual environment. This way, it's easier to differentiate when running ps aux.

View uwsgi processes

ps -aux | grep uwsgi

Terminate the original uwsgi process

kill -9 27543

Conclusion

This is still cumbersome—you have to manually locate the uwsgi process and terminate it. Next, I should look for a more convenient approach, such as adding uwsgi as a service for systemctl to manage, though the official documentation advises against doing this?

Supplementary

There are a few other ways to simplify the management of the uwsgi server.

  • Using Supervisor to manage the uwsgi service

Supervisor (http://supervisord.org/) is a client/server service developed in Python. It's a process management tool for Linux/Unix systems and does not support Windows. It can conveniently monitor, start, stop, and restart one or multiple processes. When a process managed by Supervisor is unexpectedly killed, the supervisor detects the process death and automatically restarts it, providing a convenient automatic process recovery feature without needing to write shell scripts yourself.

References:

uWSGI can run in 'emperor' mode. In this mode, it monitors a directory of uWSGI configuration files and generates an instance ('vassal') for each configuration file it finds. Whenever a configuration file is modified, the emperor will automatically restart the vassal.

Reference: http://uwsgi-docs-zh.readthedocs.io/zh_CN/latest/tutorials/Django_and_nginx.html

Following international convention, a picture is placed at the end of the article as a cover.

About


For more interesting tips, follow my WeChat public account: DealiAxy All articles are also available on my blog: blog.deali.cn

_EOF_

About the management of the uwsgi server

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

聊聊Django应用的部署和性能的那些事儿

前言 随着工作的深入,我越来越发现Python Web开发中有很多坑,也一直在羡慕AspNetCore和Go等的可执行文件部署和高性能,以及Spring生态的丰富,不过因为工作用了Django,生活还是要继续的嘛,这Django好歹也是有很大份额的Web框架,也没那么不堪,至少开发速度上就吊打一众框架了~ 在之前的文章里我介绍过使用Docker部署Django应用的方法,不过那种部署方式只适合上线

2022-05-27 · Django · 约 1 分钟

Django项目引入NPM和gulp管理前端资源

前言 之前写了一篇《Asp-Net-Core开发笔记:使用NPM和gulp管理前端静态文件》,现在又来用Django开发项目了,之前我搞了一个Django的快速开发脚手架「DjangoStarter」,正好给升级一下~ 关于npm和gulp我就不多重复了,之前那篇文章都写了,直接上操作 安装依赖 安装依赖的操作跟上一篇文章是一样的,不过我这里直接提供package.json文件,复制到项目根目录里

2022-04-02 · Django · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…