Reputation: 572
I am running SocketIOServer for my flask app and I have a run.py script which looks like this:
import sys
from idateproto import create_app, run_app
if __name__ == "__main__":
if len(sys.argv) > 1:
create_app(sys.argv[1])
else:
create_app('dev')
run_app()
and run_app looks like this:
def run_app():
# Run the application
# See flask/app.py run() for the implementation of run().
# See http://werkzeug.pocoo.org/docs/serving/ for the parameters of Werkzeug's run_simple()
# If the debug parameter is not set, Flask does not change app.debug, which is set from
# the DEBUG app config variable, which we've set in create_app().
#app.run(**app_run_args)
global app
global middleware
SocketIOServer((app.config['HOST'], app.conf`enter code here`ig['PORT']), middleware,namespace="socket.io", policy_server=False).serve_forever()
I run this like: python run.py production/dev/test etc.
Now I want to run it in production using gunicorn and all the tutorials online suggest doing something like: gunicorn run:app -c gunicorn-config.py My problem is I don't want to run just my app any more. I want to tell gunicorn to run the serve_forever method on the SocketIOServer instead, I have done a lot of research online and can not find a way to achieve this. Please help.
Upvotes: 2
Views: 1004