我正在为 Heroku 上的 Django 应用程序寻找有效的 uwsgi 配置。
目前我有
uWSGI==1.4.4
在requirements.txt
和:
# this is in a single line:
web: uwsgi --http-socket=$PORT --home=$HOME
--module="myapp.wsgi:application"
--master --vacuum --processes=1 --plugins=python
--virtualenv="/app/.heroku/python/"
在Procfile
. 但这失败了:
2013-01-15T11:48:17+00:00 app[web.1]: open("./python_plugin.so"): No such file or directory [core/utils.c line 4733]
2013-01-15T11:48:17+00:00 app[web.1]: machine: x86_64
2013-01-15T11:48:17+00:00 app[web.1]: !!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
2013-01-15T11:48:17+00:00 app[web.1]: nodename: 71650ed5-006c-4395-8be5-276408f42efb
2013-01-15T11:48:17+00:00 app[web.1]: os: Linux-2.6.32-350-ec2 #57-Ubuntu SMP Thu Nov 15 15:59:03 UTC 2012
2013-01-15T11:48:17+00:00 app[web.1]: *** Starting uWSGI 1.4.4 (64bit) on [Tue Jan 15 11:48:17 2013] ***
2013-01-15T11:48:17+00:00 app[web.1]:
lock engine: pthread robust mutexes
2013-01-15T11:48:17+00:00 app[web.1]: detected max file descriptor number: 10000
2013-01-15T11:48:17+00:00 app[web.1]: current working directory: /app
2013-01-15T11:48:17+00:00 app[web.1]: detected binary path: /app/.heroku/python/bin/uwsgi
2013-01-15T11:48:17+00:00 app[web.1]: your processes number limit is 256
2013-01-15T11:48:17+00:00 app[web.1]: detected number of CPU cores: 4
2013-01-15T11:48:17+00:00 app[web.1]: uwsgi socket 0 bound to UNIX address 25699 fd 3
2013-01-15T11:48:17+00:00 app[web.1]: clock source: unix
2013-01-15T11:48:17+00:00 app[web.1]: *** Operational MODE: single process ***
2013-01-15T11:48:17+00:00 app[web.1]: compiled with version: 4.4.3 on 15 January 2013 11:11:38
2013-01-15T11:48:17+00:00 app[web.1]: Python version: 2.7.2 (default, Oct 31 2011, 16:22:04) [GCC 4.4.3]
2013-01-15T11:48:17+00:00 app[web.1]: Set PythonHome to /app/.heroku/python/
2013-01-15T11:48:17+00:00 app[web.1]: your memory page size is 4096 bytes
2013-01-15T11:48:17+00:00 app[web.1]: Python main interpreter initialized at 0x123dd80
2013-01-15T11:48:17+00:00 app[web.1]: *** Python threads support is disabled. You can enable it with --enable-threads ***
2013-01-15T11:48:17+00:00 app[web.1]: your server socket listen backlog is limited to 100 connections
2013-01-15T11:48:17+00:00 app[web.1]: mapped 144784 bytes (141 KB) for 1 cores
2013-01-15T11:48:17+00:00 app[web.1]: Traceback (most recent call last):
2013-01-15T11:48:17+00:00 app[web.1]: File "./myapp/wsgi.py", line 23, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 8, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: from django.core.wsgi import get_wsgi_application
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 1, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: from django import http
2013-01-15T11:48:17+00:00 app[web.1]: from django.core.handlers.wsgi import WSGIHandler
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/http/__init__.py", line 116, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: from django.utils.crypto import constant_time_compare, salted_hmac
2013-01-15T11:48:17+00:00 app[web.1]: from django.core import signing
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/crypto.py", line 13, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/signing.py", line 42, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: from os import urandom as _urandom
2013-01-15T11:48:17+00:00 app[web.1]: ImportError: cannot import name urandom
2013-01-15T11:48:17+00:00 app[web.1]: import random
2013-01-15T11:48:17+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/random.py", line 47, in <module>
2013-01-15T11:48:17+00:00 app[web.1]: *** no app loaded. going in full dynamic mode ***
2013-01-15T11:48:17+00:00 app[web.1]: unable to load app 0 (mountpoint='') (callable not found or import error)
2013-01-15T11:48:17+00:00 app[web.1]: spawned uWSGI master process (pid: 2)
2013-01-15T11:48:17+00:00 app[web.1]: *** uWSGI is running in multiple interpreter mode ***
2013-01-15T11:48:17+00:00 app[web.1]: spawned uWSGI worker 1 (pid: 3, cores: 1)
2013-01-15T11:49:17+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2013-01-15T11:49:17+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-01-15T11:49:18+00:00 heroku[web.1]: Process exited with status 137
2013-01-15T11:49:18+00:00 heroku[web.1]: State changed from starting to crashed
我猜第二个错误 ( ImportError: cannot import name urandom
) 可能是第一个错误 ( open("./python_plugin.so"): No such file or directory
)的结果
该应用程序在默认的 Django 开发 HTTP 服务器上运行良好。
任何想法如何解决这一问题?非常欢迎指向工作配置的指针。