Direct launch of Gunicorn in python through an egg

I am using gunicorn w / wsgi (no paster or django) to start flask. Now I'm curious to create an egg pack for my application and run it directly. When I do this, my application starts to run, but does not initialize.

Script

# 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

      

Code: 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)

      

And here's the output:

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.

      

I know the Flask docs use Flask ( name ) to initialize the app, but since my server code is nested in a package that won't work, at least as far as I can tell. If maybe there is a way to load the code from the .module X package, but refer to a different name between the gun and the flask?

+3
python flask gunicorn


source to share


No one has answered this question yet

Check out similar questions:

5504
Does Python have a ternary conditional operator?
5231
What are metaclasses in Python?
4473
Calling an external command in Python
3790
How can I safely create a subdirectory?
3602
Does Python have a substring method "contains"?
3119
What is the difference between Python list methods that are appended and expanded?
2818
Finding the index of an element by specifying the list that contains it in Python
2601
How can I make a time delay in Python?
2568
How to find the current time in Python
2097
Is there a way to run Python on Android?



All Articles
Loading...
X
Show
Funny
Dev
Pics