Reputation: 121
I am not familiar with gunicorn and system administration and trying to deploy it on server.
Running of process is very easy and I did it using command
gunicorn -c gunicorn_config.py --bind 127.0.0.1:8000 -k gevent_wsgi --daemon wsgi:app
gunicorn_config.py
workers = 2
worker_class = 'socketio.sgunicorn.GeventSocketIOWorker'
transports = ['websockets', 'xhr-polling']
bind = '127.0.0.1:8000'
pidfile = '/tmp/gunicorn.pid'
debug = False
loglevel = 'info'
errorlog = '/tmp/gunicorn.log'
resource = "socket.io"
wsgi.py
import os.path as op
import werkzeug.serving
import gevent.monkey
gevent.monkey.patch_all()
from bakery import create_app, init_app
app = create_app(app_name='bakery')
app.config.from_object('config')
app.config.from_pyfile(op.join(op.realpath(op.dirname(__name__)), 'local.cfg'))
init_app(app)
from socketio.server import SocketIOServer
SocketIOServer(('0.0.0.0', 5000), app,
resource="socket.io", policy_server=True,
transports=['websocket', 'xhr-polling'],
).serve_forever()
nginx is set up to use in location
proxy_pass http://localhost:8000
gunicorn successfully runs but after several manipulation on app it crashes with KeyError 'wsgi.websocket'. Seems that transport websocket is not enough for that, but I am not sure.
Upvotes: 2
Views: 1610
Reputation: 4054
The reason might be an issue when using multiple gunicorn workers, see: https://github.com/abourget/gevent-socketio/issues/132
Try setting the number of workers to one to see if this is indeed the case.
Upvotes: 0
Reputation: 1308
I had this issue; nginx needs to be configured to proxy web sockets: http://nginx.org/en/docs/http/websocket.html.
Upvotes: 1