【问题标题】:how to deploy two web.py apps using uwsgi?如何使用 uwsgi 部署两个 web.py 应用程序?
【发布时间】:2013-04-09 23:00:42
【问题描述】:

我将使用 web.py 进行一些工作,我不知道如何处理两个应用程序同时 使用 uwsgi 部署。以下是我的作品。

我的目录树,两个最简单的应用程序:

├── index
│   └─── index.py   
└── index2
    └─ index2.py

还有我原来的 uwsgi.ini:

[uwsgi]
plugin = python27
http = :8080
master = true
module = index

当只处理一个应用程序时,我可以在 'index' 目录中 cp uwsig.ini ,然后 运行“uwsgi ./uwsgi.ini”,这样我就可以访问端口 8080 上的应用程序,但是如果有的话 两个或多个应用程序,有什么例子吗?

index.py 和 index2.py 几乎一样。

index.py:

# -*- coding: UTF-8 -*-
import web

urls = (
    '/index', 'Index',
)

class Index:
    def GET(self):
        return 'index'

app = web.application(urls, globals())
application = app.wsgifunc()

index2.py:

# -*- coding: UTF-8 -*-
import web

urls = (
    '/index2', 'Index',
)

class Index:
    def GET(self):
        return 'index2'

app = web.application(urls, globals())
application = app.wsgifunc()

谢谢!

【问题讨论】:

    标签: python web.py uwsgi


    【解决方案1】:

    我建议为此使用 webpy 的子应用程序。

    看这里:http://webpy.org/cookbook/subapp

    您的另一个选择是配置反向代理 (nginx),方法是让几个 uwsgi 进程监听不同的套接字并让 nginx 管理请求的去向。在 nginx conf 中是这样的:

    location /index {
        uwsgi_pass  unix:/path/to/uwsgi1.sock;
        include uwsgi_params;
    }
    location /index2 {
        uwsgi_pass  unix:/path/to/uwsgi2.sock;
        include uwsgi_params;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-16
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      相关资源
      最近更新 更多