未找到 uwsgi 错误 python 应用程序 [英] uwsgi error python application not found

查看:59
本文介绍了未找到 uwsgi 错误 python 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用 uwsgi 和 python 配置了我的 nginx 服务器,当我尝试通过点击浏览器中的 url 来运行我的 python 应用程序时,浏览器返回消息,未找到 uwsgi 错误 python 应用程序.

I've configured my nginx server with uwsgi and python and when I try to run my python application by hitting the url in my browser, the browser returns the message, uwsgi error python application not found.

这是我的 uwsgi 日志的样子:

This is what my uwsgi log looks like:

*** Starting uWSGI 1.0.4 (32bit) on [Tue Jul 31 15:25:04 2012] ***
compiled with version: 4.6.3 on 27 July 2012 17:02:36
current working directory: /home/paul/Desktop/x/studio
detected binary path: /home/paul/Desktop/x/studio/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
*** WARNING: you are running uWSGI without its master process manager ***
your memory page size is 4096 bytes
probably another instance of uWSGI is running on the same address.
bind(): Address already in use [socket.c line 598]
[pid: 3868|app: -1|req: -1/11] 127.0.0.1 () {38 vars in 911 bytes} [Tue Jul 31 15:25:22      2012] GET /ai?api=%3CIron%3E%3CAction%3E%3CService%3EUserAuth%3C/Service%3E%3CUsername%3Eadmin%3C/Username%3E%3CPassword%3Eadmin%3C/Password%3E%3C/Action%3E%3C/Iron%3E => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 3864|app: -1|req: -1/12] 127.0.0.1 () {38 vars in 655 bytes} [Tue Jul 31 15:25:34 2012] GET /ai?api=%3CIron%3E%3C/Iron%3E => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 3864|app: -1|req: -1/13] 127.0.0.1 () {38 vars in 655 bytes} [Tue Jul 31 15:25:38  2012] GET /ai?api=%3CIron%3E%3C/Iron%3E => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 3864|app: -1|req: -1/14] 127.0.0.1 () {38 vars in 655 bytes} [Tue Jul 31 15:25:48 2012] GET /ai?api=%3CIron%3E%3C/Iron%3E => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 3868|app: -1|req: -1/15] 127.0.0.1 () {38 vars in 655 bytes} [Tue Jul 31 15:26:11 2012] GET /ai?api=%3CIron%3E%3C/Iron%3E => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)

uwsgi 和 nginx 是使用

uwsgi and nginx is invoked from my virtualenv root using

bin/uwsgi -p 2 --socket  127.0.0.1:8807 --module index --pythonpath ironjob/ai -d log/uwsgi_ai.log
bin/nginx -p ./ -c ironjob/etcs/production/nginx.conf

~

这是我的 nginx.conf 文件

this is my nginx.conf file

server {
    listen      8090;
    server_name example.com;
    charset     utf-8;

    # Django admin media.
    location /media/admin/ {
      alias lib/python2.6/site-packages/django/contrib/admin/media/;
    }
    # Your project's static media.
    location /media/ {
      alias PROJECT_ROOT/media/;
    }

    # Finally, send all non-media requests to the Django server.
   location /ai {
      uwsgi_pass  127.0.0.1:8807;
      include     uwsgi_params;
    }
  }

以及包含可调用应用程序的 $VIRTUVAL_ENV/ironjob/ai/index.py 文件:

and the $VIRTUVAL_ENV/ironjob/ai/index.py file that contains the callable application:

import os
import sys
from webob import Response
from cgi import parse_qs, escape
import urllib

from ironMainManager import MainManager

os.environ['PYTHONJ_EGG_CACHE'] = '$VIRTUAL_ENV/bin/.python-egg'

def application(environ , start_response):
    mManager = MainManager()
    parameters = parse_qs(environ.get('QUERY_STRING', ''))
    returnval ="<Root></Root>"

    if 'api' in parameters:
        api = parameters['api'][0]
        if 'platform' in parameters:
                platform = parameters['platform'][0]
                if platform == 'browser':
                       api = urllib.unquote(str(parameters['api'][0]))
        print api
        returnval = mManager.process(api)
        output = 'success'
    else:
        output = 'error'

    res = Response()
    res.content_type = 'text/plain'
    res.body=str(returnval)
    return res(environ, start_response)

推荐答案

看起来你有一个旧的 uWSGi 实例已经在运行.确保杀死所有剩余的实例并重新启动 uWSGI.除此之外,请尝试始终使用最新的稳定版(1.0现在已经很老了)

It looks like you have an old uWSGi instance already running. Be sure to kill all of the remaining instances and restart uWSGI. In addition to this try to always use the latest stable (1.0 is pretty old now)

这篇关于未找到 uwsgi 错误 python 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆