Adding Socket.IO to existing Django/WSGI project

一笑奈何 提交于 2019-12-04 20:31:51

My final solution to this was using the built-in runserver_socketio command for the manage.py script, running on 0.0.0.0:9000. I'm using Ubuntu so I made an upstart config to keep it alive. Seems to be working just fine running alongside my Apache/WSGI server. If anyone has a better solution please speak up.

A approach I came up with was using the wsgi the apache uses to instance a thread that just calls the runserver_socketio command. That's not, for sure, the best approach. But if someone finds a better solution. Let us know in this post.

def init_socketio():
    os.system('python manage.py runserver_socketio 0.0.0.0:9000')

socketio_thread = Thread(target=init_socketio, args=())
socketio_thread.start()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!