2014-04-16 28 views
0

我正在使用Dashing-rails(使用Rufus-scheduler)将更新发送到浏览器窗口小部件。ActiveRecord :: ConnectionTimeoutError由于未发布的ActiveRecord连接通过Dashing

从浏览器向页面发出5次不同请求后,由于以下原因导致站点崩溃:“ActiveRecord :: ConnectionTimeoutError”。

我的假设是,每个浏览器equests触发器创建rufus调度器线程。这个线程发送更新并且线程保持到ActiveRecord连接而不让它发生,最终导致超时。

但是,我试图确保计划释放连接到ActiveRecord池无济于事。

Dashing.scheduler.every '10s', :allow_overlapping => false do 
    ActiveRecord::Base.connection_pool.with_connection do 
    Dashing.send_event('past_hour', { value: Device.sightings_past_hour }) 

    d = Device.where("company != ''").last 
    company = d.company !="" ? d.company : "Device Manufacturer Not Found" 
    Dashing.send_event('last_MAC', { text: "#{company}", 
           moreinfo: "MAC Address: #{d.macaddress}"}) 
    Dashing.send_event('macaddresses', { current: Device.total_Count }) 
top_manufacturers=Device.manufacturers_dashboard 
    Dashing.send_event('manufacturers', {items: top_manufacturers}) 
    Dashing.send_event('past_day', { current: Device.sightings_past_day }) 
end 
    ActiveRecord::Base.connection_pool.release_connection 
end 

有没有办法看到哪些进程正在每个线程上运行/什么持有ActiveRecord连接?或者如果这是个问题,防止Dashing-rails保持ActiveRecord连接?

回答