Serving in uWSGI #81

Closed
marconi opened this Issue Aug 14, 2012 · 9 comments

Comments

Projects
None yet
3 participants
Contributor

marconi commented Aug 14, 2012

How do I serve my Django site using uWSGI with the SocketIOServer? I tried using the following uwsgi config:

[uwsgi]
socket = 127.0.0.1:3031
master = true
processes = 2
env = DJANGO_SETTINGS_MODULE=demo.settings
module = run

and I have run.py:

from gevent import monkey
from socketio.server import SocketIOServer
import django.core.handlers.wsgi
import os
import sys

monkey.patch_all()

PORT = 3031

os.environ['DJANGO_SETTINGS_MODULE'] = 'demo.settings'

application = django.core.handlers.wsgi.WSGIHandler()
SocketIOServer(('', PORT), application, namespace="socket.io").serve_forever()

but it just keeps on loading. Any ideas on how I might tell uWSGI to use SocketIOServer for serving my app?

Contributor

dswarbrick commented Aug 14, 2012

You should probably ask this on the uWSGI lists/forums, as it's more a case of "how do I use WebSockets under uWSGI?" I believe there has been some work done in that area, but since WebSockets are essentially incompatible with the WSGI 1.0 spec, it's unlikely to work.

Collaborator

sontek commented Aug 14, 2012

You also need gevent to work, and uWSGI has horrible gevent support ( http://projects.unbit.it/uwsgi/wiki/Gevent ), so I would recommend using gunicorn instead.

Contributor

marconi commented Aug 14, 2012

Hey guys, thanks will try it but I wonder if Gunicorn works with Apache? I'm pretty much stuck with it, do you think it will work the same as with Nginx if I use proxy pass in Apache to Gunicorn or do you recon there might be some issues?

Contributor

dswarbrick commented Aug 14, 2012

Gunicorn can serve content completely independently of Apache, or you can use Apache's mod_proxy to hand requests to a backend Gunicorn server (but WebSockets won't work through mod_proxy).

Contributor

marconi commented Aug 14, 2012

@dswarbrick yayks, just as when I was thinking all request comes in apache and just forward the socketio related to gunicorn. :/ Could you enlighten me why gunicorn won't work under mod_proxy?

Collaborator

sontek commented Aug 14, 2012

@marconi What I use is gunicorn with a gevent worker and nginx as a proxy with buffering off. Its very fast/scalable and works just the way you would want it to.

Contributor

marconi commented Aug 14, 2012

@sontek the thing is, our sysad is quite attached to Apache. I'll give it another shot, might be able to convince him this time. :)

Collaborator

sontek commented Aug 14, 2012

Yeah, you can use apache. I know someone who does HAProxy + Apache but I haven't done it.

Contributor

dswarbrick commented Aug 14, 2012

@sontek Can you elaborate on what you mean by using nginx as a proxy? Is that proxying WebSockets?

@sontek sontek closed this Nov 23, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment