2

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

我已经尝试了几种配置,这些配置已成功用于专用服务器上的部署。然而,Heroku 一直抱怨 uwsgi 没有在正确的端口上监听,即使我在我的 Procfile 中使用了 $PORT 环境变量。

档案

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

conf/uwsgi.ini

(请注意,我已经尝试了一堆配置调整,这是我尝试过的最简单的一个,关于错误的端口号总是相同的错误。)

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。关于为什么这不起作用的任何想法?

4

1 回答 1

3

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

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

于 2012-03-31T05:33:00.470 回答