工头开始找不到应用程序:'soapbar'

时间:2014-03-20 13:32:25

标签: python heroku flask

我按照这里的heroku快速入门指南进行操作:https://devcenter.heroku.com/articles/getting-started-with-python

我被困在工头开始部分。这是我的目录所看到的。我只是运行一个基本的网络应用程序。没有框架或任何东西。

soapbar/
    Procfile.txt
    soapbar/
        soapbar.py
        __init__.py
    venv/
        Include/
        Lib/
        Scripts/ 

这是我的Procfile中的内容:

web: gunicorn soapbar.soapbar:app

这是堆栈跟踪:

09:28:54 web.1  | started with pid 34567
09:28:54 web.1  | 2014-03-20 09:28:54 [34567] [INFO] Starting gunicorn 18.0
09:28:54 web.1  | 2014-03-20 09:28:54 [34567] [INFO] Listening at: http://0.0.0.0:5000 (34567)
09:28:54 web.1  | 2014-03-20 09:28:54 [34567] [INFO] Using worker: sync
09:28:54 web.1  | 2014-03-20 09:28:54 [34570] [INFO] Booting worker with pid: 34570
09:28:54 web.1  | Failed to find application: 'soapbar.soapbar'
09:28:54 web.1  | 2014-03-20 09:28:54 [34570] [INFO] Worker exiting (pid: 34570)
09:28:54 web.1  | 2014-03-20 09:28:54 [34567] [INFO] Shutting down: Master
09:28:54 web.1  | 2014-03-20 09:28:54 [34567] [INFO] Reason: App failed to load.
09:28:54 web.1  | exited with code 4
09:28:54 system | sending SIGTERM to all processes
SIGTERM received

请帮忙。

这是soapbar.py:

import logging
import os

from spyne.application import Application
from spyne.decorator import srpc
from spyne.interface.wsdl import Wsdl11
from spyne.protocol.soap import Soap11
from spyne.service import ServiceBase
from spyne.model.complex import Iterable
from spyne.model.primitive import Integer
from spyne.model.primitive import String
from spyne.server.wsgi import WsgiApplication

class MessageService(ServiceBase):
    @srpc(String, Integer, _returns=Iterable(String))
    def send_message(msg):
        yield 'Your message: %s' % msg

if __name__=='__main__':
    try:
        from wsgiref.simple_server import make_server
    except ImportError:
        print "Error: server requires Python >= 2.5"

    logging.basicConfig(level=logging.INFO)
    logging.getLogger('spyne.protocol.xml').setLevel(logging.DEBUG)

    application = Application([MessageService], 'org.temporary.soap',
            interface=Wsdl11(), in_protocol=Soap11(), out_protocol=Soap11())

    port = int(os.environ.get('PORT', 5000))

    server = make_server('0.0.0.0', port, WsgiApplication(application))

    print "listening to http://0.0.0.0:%s" % port
    print "wsdl is at: http://0.0.0.0:%s/?wsdl" % port

    server.serve_forever()

2 个答案:

答案 0 :(得分:0)

这可能不是你的整个问题,但看看heroku在该教程中使用的烧瓶示例,他们实际上有一个在python文件中定义的'app'变量(wsgi服务器)(不在 main )。这就是为什么他们的工头文件有:app。你的也有:app,但你没有定义应用程序。

import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello World!'

答案 1 :(得分:0)

重命名' Procfile.txt'到 Procfile

希望它能解决问题

请按照文档了解详细信息 Procfile