2014-09-23 2 views
1

Flask 응용 프로그램을 사용하여 UWSGI를 설정하는 과정에서 Linode guide을 따랐습니다. 샘플 응용 프로그램을 만들 때까지 모든 것이 정상적으로 처리됩니다. "uWSGI Error Python 응용 프로그램을 찾을 수 없습니다".Flask with UWSGI : 파이썬 응용 프로그램을 찾을 수 없습니다.

/srv/www/xxx.com/xxx/ 내 파일의 구조는 다음과 같습니다

#!flask/bin/python 

from app import app 

if __name__ == "__main__": 
    app.run(debug = False) 
:

if __name__ == '__main__': 
    app.run() 

그리고 uwsgi.py이 응용 프로그램을 가져옵니다

app/ 
    __init__.py 
uwsgi.py 

__init__.py 파일이 응용 프로그램을 실행하기위한 라인을 가지고

수동으로 실행하려고하면 python uwsgi.py 앱이 작동하는 것처럼 보이므로 오류나 잘못된 가져 오기가 없습니다. I (예에서) 이런 식으로 uwsgi.py의 내용을 변경하는 경우 :

import os 
import sys 

sys.path.append('/srv/www/example.com/application') 

os.environ['PYTHON_EGG_CACHE'] = '/srv/www/example.com/.python-egg' 

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
        ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

응용 프로그램은 실행하는 것, 그래서 UWSGI와의 nginx가 제대로 작동하고 uwsgi.py 파일을 실행하는,하지만 난 그것을 지적하지 않을 때 내 애플 리케이션.

내 uwsgi 설정 :

<uwsgi> 
    <plugin>python</plugin> 
    <socket>/run/uwsgi/app/xxx.com/xxx.com.socket</socket> 
    <pythonpath>/srv/www/xxx.com/application/xxx/</pythonpath> 
    <app mountpoint="/"> 

     <script>uwsgi</script> 

    </app> 
    <master/> 
    <processes>4</processes> 
    <harakiri>60</harakiri> 
    <reload-mercy>8</reload-mercy> 
    <cpu-affinity>1</cpu-affinity> 
    <stats>/tmp/stats.socket</stats> 
    <max-requests>2000</max-requests> 
    <limit-as>512</limit-as> 
    <reload-on-as>256</reload-on-as> 
    <reload-on-rss>192</reload-on-rss> 
    <no-orphans/> 
    <vacuum/> 
</uwsgi> 

내의 nginx의 구성 :

server { 
     listen   80; 
     server_name  $hostname; 
     access_log /srv/www/xxx.com/logs/access.log; 
     error_log /srv/www/xxx.com/logs/error.log; 

     location/{ 
      uwsgi_pass  unix:///run/uwsgi/app/xxx.com/xxx.com.socket; 
      include   uwsgi_params; 
      uwsgi_param  UWSGI_SCHEME $scheme; 
      uwsgi_param  SERVER_SOFTWARE nginx/$nginx_version; 

     } 

     location /static { 
      root /srv/www/xxx.com/public_html/static/; 
      index index.html index.htm; 

     } 

} 

그리고 이것은 uwsgi 오류 로그입니다 :

added /srv/www/xxx.com/application/xxx/ to pythonpath. 
- unable to load app 0 (mountpoint='/') (callable not found or import error) 
- *** no app loaded. going in full dynamic mode *** 
- *** uWSGI is running in multiple interpreter mode *** 
- spawned uWSGI master process (pid: 21982) 
- spawned uWSGI worker 1 (pid: 21990, cores: 1) 
- set cpu affinity for worker 1 toTue Sep 23 16:51:19 2014 - 0Tue Sep 23 16:51:19 2014 - 
- spawned uWSGI worker 2 (pid: 21991, cores: 1) 
- *** Stats server enabled on /tmp/stats.socket fd: 14 *** 
- set cpu affinity for worker 2 toTue Sep 23 16:51:19 2014 - 0Tue Sep 23 16:51:19 2014 - 

누구든지 나를 가리킬 수 있습니다 내가 만드는 중이라서 곳 실수? 여러 가지 해결책을 시도하면서 몇 시간을 보냈지만 아무 것도 작동하지 않는 것처럼 보였습니다. 중요한 것을 생략했는데 찾을 수 없었습니다.

답변

1

시도해주세요. <callable>application</callable>

+0

여전히 동일합니다. 'application'으로 시도하고'app'로 시도했습니다. –

+1

와우, 나는 그럭저럭 할 수 있었다. 나는 ' app'과 ' app'을 추가했다. 아무도 왜 이것이 원인인지, 왜이 일이 이렇게 정의되어야 하는지를 알고 있습니까? –

+0

uWSGI는 '응용 프로그램'이라는 호출 가능 파일을 찾습니다. 다른 이름으로 부르는 경우 이름이 무엇인지 알아야합니다. – dirn

관련 문제