I have a flask application.
I run it in production with this command:
python -m gunicorn -w 1 -b 0.0.0.0:5000 "path.to.wsgi:return_app()"
Instead, I want to run it inside a my_file.py
I need a function to run and it should accept the app object and port binding and number of workers
How can I do that?
I need something like this psudo code:
import gunicorn
app = return_app()
gunicorn(workers=1, ip="0.0.0.0", port=5000, app=app)
the most important part to me is the app=app
part
the main point is that I want to use the app object as an instance of Flask(). I want to directly give app object to gunicorn not throough addressing it in a string
What I have tried: I have opened gunicorn library main.py file
from gunicorn.app.wsgiapp import run
run()
to see how it works but could not figure it out
def run():
"""\
The ``gunicorn`` command line runner for launching Gunicorn with
generic WSGI applications.
"""
from gunicorn.app.wsgiapp import WSGIApplication
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
number_of_workers()
initialize()
and some others are missing. It would be lovely if you would complete it, so one can run it self contained. – Oldcastle