返回文章列表文章索引阅读全文
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项目笔记:sessions处理以及复杂对象序列化

前言:一点题外话 我发现,不更新博客的时候,不是非常忙,就是效率非常低。最近没怎么更新博客,原因是第二种= =。惭愧惭愧。 今天效率出奇的高,一天时间把PassNote后端的接口全部写完了,Django很好用,不过实际项目中还是有些框架不能实现的功能需要解决的,我比较喜欢造轮子,不过为了保证效率,还是尽量用现成的工具,减少不必要的折腾。 关于PassNote 之前应该在博客有说过,这是一个密码管理

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

Django全文检索实现:HayStack-+-Whoosh-+-Jieba

涉及到的工具 haystack是django的开源搜索框架,该框架支持**Solr**, Elasticsearch, Whoosh, **Xapian搜索引擎,不用更改代码,直接切换引擎,减少代码量。 搜索引擎使用Whoosh,这是一个由纯Python实现的全文搜索引擎,没有二进制文件等,比较小巧,配置比较简单,当然性能自然略低。 中文分词Jieba,由于Whoosh自带的是英文分词,对中文的分

2022-08-26 · Django · 约 1 分钟

Django中间件之实现Admin后台IP白名单

前言 Django自带的Admin管理后台很方便,但是实际生产环境真的会有挺多安全问题的,在admin的安全防护这方面,我之前就研究实现了给admin加上登录验证码和限流功能,可以参考这篇文章:给Django Admin添加验证码和多次登录尝试限制 不过就在内部使用的话就好很多,因此我们可以通过Django的中间件来实现IP过滤,所以本文中涉及到两个知识点,一个是Django的中间件,另外一个是P

2022-08-26 · Django · 约 1 分钟

讨论

共 0 条

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

加载评论中…