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

error #103

Open
wenxiaodong opened this issue Jun 22, 2016 · 1 comment
Open

error #103

wenxiaodong opened this issue Jun 22, 2016 · 1 comment

Comments

@wenxiaodong
Copy link

RuntimeError: Cannot run in multiple processes: IOLoop instance has already been initialized. You cannot call IOLoop.instance() before calling start_processes()

Can't use multiple processes?

@thekeenant
Copy link

https://groups.google.com/forum/#!topic/python-tornado/JNtWjFcVb7s

app = tornado.web.Application() 
http_server = tornado.httpserver.HTTPServer(app) 
http_server.bind(port) 
http_server.start(4) 
chat_routes = sockjs.tornado.SockJSRouter(connection.handler, '/im') 
app.add_handlers(".*", 
  [(r"/im/search", handlers.search_handler)] + 
  [(r"/favicon.ico", handlers.favicon_handler)] + 
  [(r"/test", handlers.TestHandler)] + 
  chat_routes.urls) 

Works, but take note of:

This won't work: SockJS protocol requires sticky sessions - client
should come back to same instance of the SockJS server. With
pre-forking requests will be distributed in round-robin fashion.

Advised approach:

  1. Spawn multiple sockjs-tornado processes, each listening on separate port
  2. Use haproxy to load-balance requests. Sample config: https://github.com/sockjs/sockjs-node/blob/master/examples/haproxy.cfg

Serge.

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

2 participants