Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
in env.rb

Thread.new {
  until EM.reactor_running?
    sleep 1
  end
  AMQP.start :host => 'localhost', :user => 'mapper', :pass => 'testing',
               :vhost => '/nanite'
  Nanite.identity = "mapper"
  Nanite.mapper = Nanite::Mapper.new(15)
end

or  rewrite a method that gets called upon startup

before_filter :start_nanite

def start_nanite
  def start_nanite
    AMQP.start :host => 'localhost', :user => 'mapper', :pass => 'testing',
               :vhost => '/nanite'
    Nanite.identity = "mapper"
    Nanite.mapper = Nanite::Mapper.new(15)
    true
  end
  true
end  

This will overwrite the method with a noop method after it gets hit the first time.

These are both hacks until I can get a proper callback in thin to spawn AMQP after the event loop is running.