in Quiz controller:
def start_quiz
@round = 0
Thread.new {
5.times do
Juggernaut.push("quiz_#{@quiz.id}", {:round => @round})
sleep 30
@round += 1
end
}
end
Is there any apparent reason that this should be giving me problems in
production? Juggernaut does not seem to be able to push once inside
the thread or the timing is way slow at least. Should I use something
like spawn instead?
On Nov 18, 2:33 am, Kennon Ballou <ken...@angryturnip.com> wrote:
> Are you passing :threadsafe => true to your Redis instantiation? This smells like something to do with redis-rb and not juggernaut…
>
> smime.p7s
> 6KViewDownload
The juggernaut gem requires the redis gem (redis-rb) automatically as a dependency. You can set the threadsafe option by making a initializer, try something like this:
config/initializer/juggernaut.rb:
require 'juggernaut'
Juggernaut.options = {:threadsafe => true}
From my looking through the juggernaut gem this should at least set that option when it connects to Redis (I don't really know how to test that though). Give that a try and see if it makes a difference.
KB
> smime.p7s
> 6KViewDownload
Thread.new {
sleep 1
message = "<div class='chat_line'>TestUser: 1</div>"
Juggernaut.publish(channel, message)
sleep 2
message = "<div class='chat_line'>TestUser: 2</div>"
Juggernaut.publish(channel, message)
sleep 5
message = "<div class='chat_line'>TestUser: 3</div>"
Juggernaut.publish(channel, message)
}
Then if I call Juggenaut.publish anywhere else, the first message
comes through. And if I wait another 10 seconds and call
Juggernaut.publish, the second message comes through... This is only
happening in my production environment where I am using Thin and
Nginx, so it might have nothing to do with Juggernaut, but I am really
at a loss.
--
You received this message because you are subscribed to the Google Groups "Juggernaut 2" group.
To post to this group, send email to juggernaut...@googlegroups.com.
To unsubscribe from this group, send email to juggernaut-for-r...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/juggernaut-for-rails?hl=en.
def self.start
Thread.new {
Juggernaut.push("quiz_#{self.id}", {:round => @round})
@round += 1
sleep 30
}
end
I looked into things like spawn to handle this, but I figured Threads
would work just as well. It works fine in my development environment.