Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serving in uWSGI #81

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

Serving in uWSGI #81

marconi opened this issue Aug 14, 2012 · 9 comments

Comments

@marconi
Copy link
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?

@dswarbrick
Copy link
Contributor

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.

@sontek
Copy link
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.

@marconi
Copy link
Contributor Author

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?

@dswarbrick
Copy link
Contributor

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).

@marconi
Copy link
Contributor Author

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?

@sontek
Copy link
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.

@marconi
Copy link
Contributor Author

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. :)

@sontek
Copy link
Collaborator

sontek commented Aug 14, 2012

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

@dswarbrick
Copy link
Contributor

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

@sontek sontek closed this as completed Nov 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants