Gunicorn通过蛋直接在蟒蛇中发射

时间:2014-11-06 23:43:43

标签: python flask gunicorn

我正在使用gunicorn w / wsgi(没有贴纸或django)来运行烧瓶。现在我有兴趣为我的应用程序构建一个egg包并直接运行它。当我这样做时,我的应用程序开始启动,但无法初始化。

脚本

# note the PYTHONPATH is already set to my .egg, which is confirmed by the output below
python setup.py bdist_egg; python -m gunicorn.app.wsgiapp server.dummy

代码:server / dummy.py

from flask import *
from util.config import setting
import logging
from logging import FileHandler

app = Flask('server.dummy')
app.debug = True

file_handler = FileHandler("/tmp/flask.log")
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)

mydumbblueprint = Blueprint('mydumbblueprint', __name__)

@mydumbblueprint.route('/')
def whatever():
    return jsonify({'whatever': 'is right!'})

app.register_blueprint(mydumbblueprint)
app.logger.info('loading: %s' % app.name)

这是输出:

2014-11-06 15:37:19 [64098] [INFO] Starting gunicorn 18.0
2014-11-06 15:37:19 [64098] [INFO] Listening at: http://127.0.0.1:8000 (64098)
2014-11-06 15:37:19 [64098] [INFO] Using worker: sync
2014-11-06 15:37:19 [64101] [INFO] Booting worker with pid: 64101
--------------------------------------------------------------------------------
INFO in dummy [/Volumes/opt/src/dio/distillerizer/server/dummy.py:20]:
loading: server.dummy
--------------------------------------------------------------------------------
Failed to find application: 'server.dummy'
2014-11-06 15:37:20 [64101] [INFO] Worker exiting (pid: 64101)
2014-11-06 15:37:20 [64098] [INFO] Shutting down: Master
2014-11-06 15:37:20 [64098] [INFO] Reason: App failed to load.

我知道Flask文档使用Flask(名称)来初始化应用程序,但由于我的服务器代码嵌套在一个至少在我无法解释的程序包中。如果可能有一种方法可以从package.module X加载代码,但是引用了gunicorn和amp;之间的另一个名称。烧瓶?

0 个答案:

没有答案