uwsgi + django 通过 Nginx - uwsgi 设置/生成?

发布于 2024-09-08 14:56:07 字数 82 浏览 16 评论 0原文

我的 Django 应用程序倾向于 uwsgi+nginx,任何人都可以分享启动我的 uwsgi 进程的最佳方法吗?有人有调整 uwsgi 的经验吗?

I am leaning towards uwsgi+nginx for my Django app, can anyone share the best method for starting up my uwsgi processes? Does anyone have experience tuning uwsgi?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

等往事风中吹 2024-09-15 14:56:07

OSX Upstart/init 上启动

在 unice 上的

。 uwsgi也有它自己的进程管理器,所以你也可以运行它。

调整:

查看邮件列表,获取有关您特定要求的建议。 Uwsgi 非常棒,它是一个完整的部署解决方案。

0.8.40 以上的 Nginx 将默认构建 uwsgi 绑定,构建 nginx,构建 uwsgi 就可以了。

Launchd on OSX

Upstart/init on the unices.

uwsgi also has its own process manager, so you can just run that as well.

Tuning:

Check the mailing list, for advice on your particular requirements. Uwsgi is amazing, it is a complete deploy solution.

Nginx above 0.8.40 will build the uwsgi bindings by default, Build nginx, build uwsgi and you are golden.

仄言 2024-09-15 14:56:07

这些是我在 fabfile.py 文件中使用的函数(如果您还没有,请查看 python Fabric):

def start_uwsgi():
    with cd(env.server.uwsgi):
        if(exists('server.pid')):
            stop_uwsgi()
            run('sleep 1')
        run('source venv/bin/activate;uwsgi --ini uwsgi.ini;'))

def stop_uwsgi():
    with cd(env.server.uwsgi):
        if(exists('server.pid')):
            run('source venv/bin/activate;uwsgi --stop server.pid;'))

在我的 uwsgi.ini 文件中,我指定:

[uwsgi]
socket = :{{your_port}}
master = true
vhost = true
no-site = true
processes = 1
enable-threads = true
pidfile = server.pid
daemonize = server.log
auto-procname = true
procname-prefix = servername_

对我来说,主要的功能是:

  • 如果您想保留,请使用 daemonise 选项uwsgi 服务器在你关闭终端/ssh 会话后
  • 使用 vhost 在同一个 uwsgi 实例下运行多个站点,如果你的瓶颈是内存,这非常好,就像我的一样,其他很棒的 webfaction 主机
  • pidfile 跟踪当前实例,使你能够调用 uwsgi --stop pidfile、uwsgi --start pidfile
  • procname 和 procname-prefix/append 为您的进程提供一个好听的名称,以便您可以使用 ps -u username | 轻松地将其挑出。 grep 一些_字符串

these are the functions i use in my fabfile.py file (check out python fabric if you haven't already):

def start_uwsgi():
    with cd(env.server.uwsgi):
        if(exists('server.pid')):
            stop_uwsgi()
            run('sleep 1')
        run('source venv/bin/activate;uwsgi --ini uwsgi.ini;'))

def stop_uwsgi():
    with cd(env.server.uwsgi):
        if(exists('server.pid')):
            run('source venv/bin/activate;uwsgi --stop server.pid;'))

In my uwsgi.ini file i specify:

[uwsgi]
socket = :{{your_port}}
master = true
vhost = true
no-site = true
processes = 1
enable-threads = true
pidfile = server.pid
daemonize = server.log
auto-procname = true
procname-prefix = servername_

for me the main gotyas were:

  • use the daemonise option if you want to keep the uwsgi server going after you close your terminal/ssh session
  • use vhost to run multiple sites under the same uwsgi instance, which is great if your bottleneck is memory, like mine is with the otherwise fantastic webfaction host
  • pidfile tracks the current instance, enabling you to call uwsgi --stop pidfile, uwsgi --start pidfile
  • procname and procname-prefix/append give a nice name to your process so you can easily single it out using ps -u username | grep some_string
最冷一天 2024-09-15 14:56:07

我将使用supervisord 来管理启动、停止过程。

I will go with supervisord for managing the starting, stoping process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文