I have a Flask application that I am trying to run through Gunicorn.
I am using virtualenv and python3. If I activate my venv cd in my application database directory, run:
gunicorn mysite:app
I get:
Starting gunicorn Listening at http://127.0.0.1:8000 DEBUG:mysite.settings:>>Config() ... Failed to find application: 'mysite' Worker exiting Shutting down: master Reason: App failed to load
Search in / etc / nginx / sites -available I only have the file "default". In permitted sites I do not have a file.
In my nginx.conf file, I have:
include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*;
Application structure:
mysite
in manage.py for mysite I have the following:
logger.debug("manage.py entry point") app = create_app(app_name) manager = Manager(app) if __name__ == "__main__": manager.run()
In the __init__.py file:
def create_app(object_name): app = Flask(__name__)
In my settings.py in the application directory
class Config(object): logger.debug(">>Config()")
From inside virtualenv if I run
print(sys.path)
I found a path to python and site-packages for this virtualenv.
From what I read to start the guns, it's just a matter of installing it and launching the mysite machine guns: app
Starting gunicorn from the parent directory of mysite I get the same thing that I did not find the application: "mysite", the application did not load the error, but does not receive the registration DEBUG ... Config () (since we are clearly in the wrong directory to start). Starting gunicorn from mysite / mysite (obviously wrong) I get an exception in the ereor workflow, ImportError: There is no module named "mysite".
Any tips on how I can fire guns?