I have a Rails (web) application that I need to add (redis) pub / sub subscriber.
Below is my PubsubSubscriber class that I need to run, the application starts.
The redis connection is created in the resque.rb initialization file. I tried PubsubSubscriber.new after connecting, but when I try to start the rails server it freezes:
=> Booting Thin => Rails 3.2.13 application starting in development on http:
Unlike when the server starts successfully:
=> Booting Thin => Rails 3.2.13 application starting in development on http://0.0.0.0:5000 => Call with -d to detach => Ctrl-C to shutdown server >> Thin web server (v1.5.1 codename Straight Razor) >> Maximum connections set to 1024 >> Listening on 0.0.0.0:5000, CTRL+C to stop
Any idea why the server freezes when I try to instantiate the PubsubSubscriber class in the initializer? Is there a better place to start?
# example modified from https://github.com/redis/redis-rb/blob/master/examples/pubsub.rb class PubsubSubscriber def initialize $redis.psubscribe( :channel_one ) do |on| on.psubscribe do |event, total| end on.pmessage do |pattern, event, message|
source share