uwsgi无法在Heroku上开始?

时间:2012-03-30 17:47:15

标签: django heroku uwsgi

我正在尝试使用uwsgi作为我的应用服务器将Django部署到Heroku(雪松堆栈)。

我已尝试过多次配置,我已成功用于专用服务器上的部署。然而,即使我在我的Procfile中使用$ PORT env变量,Heroku一直在抱怨uwsgi没有正在侦听正确的端口。

Procfile

web: uwsgi --http :$PORT --home $HOME --ini conf/uwsgi.ini

CONF / uwsgi.ini

(注意我已经尝试了一系列配置调整,这是我尝试过的最简单的一个,关于错误的PORT编号总是出现同样的错误。)

env = DJANGO_SETTINGS_MODULE=retargeting.settings
module = django.core.handlers.wsgi:WSGIHandler()

以下是我的heroku日志的输出:

2012-03-30T17:36:09+00:00 heroku[slugc]: Slug compilation finished2012-03-30T17:36:13+00:00 heroku[web.1]: Starting process with command `uwsgi --http :3810 --home /app --ini conf/uwsgi.ini`
2012-03-30T17:36:13+00:00 app[web.1]: [uWSGI] getting INI configuration from conf/uwsgi.ini
2012-03-30T17:36:13+00:00 app[web.1]: *** Starting uWSGI 1.1.2 (64bit) on [Fri Mar 30 17:36:13 2012] ***
2012-03-30T17:36:13+00:00 app[web.1]: compiled with version: 4.4.3 on 30 March 2012 03:51:49
2012-03-30T17:36:13+00:00 app[web.1]: current working directory: /app
2012-03-30T17:36:13+00:00 app[web.1]: detected binary path: /app/bin/uwsgi
2012-03-30T17:36:13+00:00 app[web.1]: *** WARNING: you are running uWSGI without its master process manager ***
2012-03-30T17:36:13+00:00 app[web.1]: your memory page size is 4096 bytes
2012-03-30T17:36:13+00:00 app[web.1]: detected max file descriptor number: 10000
2012-03-30T17:36:13+00:00 app[web.1]: lock engine: pthread mutexes
2012-03-30T17:36:13+00:00 app[web.1]: uWSGI http bound on :3810 fd 4
2012-03-30T17:36:13+00:00 app[web.1]: spawned uWSGI http 1 (pid: 4)
2012-03-30T17:36:13+00:00 app[web.1]: uwsgi socket 0 bound to TCP address 127.0.0.1:43681 (port auto-assigned) fd 3
2012-03-30T17:36:13+00:00 app[web.1]: Python version: 2.7.2 (default, Oct 31 2011, 16:22:04)  [GCC 4.4.3]
2012-03-30T17:36:13+00:00 app[web.1]: Set PythonHome to /app
2012-03-30T17:36:13+00:00 app[web.1]: Python main interpreter initialized at 0x134c5d0
2012-03-30T17:36:13+00:00 app[web.1]: your server socket listen backlog is limited to 100 connections
2012-03-30T17:36:13+00:00 app[web.1]: *** Operational MODE: single process ***
2012-03-30T17:36:13+00:00 app[web.1]: WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x134c5d0 pid: 3 (default app)
2012-03-30T17:36:13+00:00 app[web.1]: *** uWSGI is running in multiple interpreter mode ***
2012-03-30T17:36:13+00:00 app[web.1]: spawned uWSGI worker 1 (and the only) (pid: 3, cores: 1)
2012-03-30T17:36:14+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 43681, should be 3810 (see environment variable PORT)
2012-03-30T17:36:14+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-03-30T17:36:15+00:00 heroku[web.1]: Process exited with status 137
2012-03-30T17:36:15+00:00 heroku[web.1]: State changed from starting to crashed

从日志的第一行可以看到,正确的端口正在传递给uwsigi。有关为什么这不起作用的任何想法?

1 个答案:

答案 0 :(得分:3)

不要在heroku上使用--http。使用--http-socket。

第一个是代理解决方案,绑定在两个不同的端口上。