2013-01-15 38 views
1

我正在尋找在Heroku上Django應用程序的工作uwsgi配置。在Heroku上的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 devel的HTTP服務器的結果。

任何想法如何解決這個問題?指向工作配置的指針非常受歡迎。

回答

3

當您使用pip安裝uwsgi時,缺省情況下會創建python(和gevent)插件,因此您可以刪除--plugin選項。 - 真空只需要unix套接字(你在heroku上使用tcp套接字)。 --home和--virtualenv是synonims(我建議你使用--virtualenv,因爲它更有意義)。最後關於隨機問題,請點擊這裏:https://bugs.launchpad.net/ubuntu/+source/python-defaults/+bug/989856