tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

Dynamically generated Ports are not compatible with Rails Server/Console workflow #45

Closed pik closed 8 years ago

pik commented 8 years ago

The currently suggested advice in the README is to add require "pusher-fake/support/base" to an initializer, the problem with this approach is that Rails Console and Rails Server will now each initiate a pusher-fake webserver. One can add something like this if Rails.const_defined? 'Server' to guard for this, but now Rails Console won't have normal access to Pusher.trigger commands as it would in a production environment since it's own PusherFake socket_options do not match the ones generated by the server initializer. I can think of two ways of handling this:

a) Allow PusherFake to be configured with a static port. b) Write the dynamically resolved port to a lock-file which the initializer can read.

Perhaps there are better alternatives?

tristandunn commented 8 years ago

The README mentions that if you're using Foreman, or something similar, you'll only want to start it for a single process. Perhaps the comment on the development condition should also mention that.

In regards to configuring a static port, you should be able to set them manually in the configuration via the socket_options and web_options. The defaults are a random available port to make it easier to use in general. I think I want to avoid writing the resolved ports to a file, at least from within the library.

tristandunn commented 8 years ago

Added to the comment in 338c91a5ee911723c0246cf9626129ee76db2f56.

Let me know if you have any questions on configuring the static ports.