Start WebSockets server when Rails app starts #3

Open
threefunkymonkeys opened this Issue Jul 25, 2011 · 2 comments

Comments

Projects
None yet
2 participants

In order to provide a client-to-client communication
As the system
I want to provide a listening WebSocket server

When the application starts, make sure the websockets server starts and listen for incoming connections.
There's no port number defined yet, the example server located on lib/server.rb uses 8080, but it should change since it's a pretty commonly used port number.

Collaborator

damianfarina commented Jul 26, 2011

I need some help here, should we use an initializer? Is it a good idea to use something like system("rails runner lib/server.rb")
When the app stops, the websocket server must stop too right?

damianfarina was assigned Jul 26, 2011

Sorry for the late on the response, I didn't receive the notifications for this comment.
An initializer sounds as a good idea, however, I wouldn't go with something like system for this, since the WS server is just a ruby class, you can require it and start the server from the initializer.
You will have to separate the class definition from the example and put it on its own file, and then start it from the initializer.
Just an idea, feel free to go with whatever suits better for you. We can discuss it later.
And yes, at a first glance, I would say the ws server must stop too. We might consider, later, leaving it as a separate process for those already established connections, but I'd discuss this subject later too.
Cheers!

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