2016-09-03 59 views
0

我在heroku上運行rails應用程序,我有兩個web dynos。 我該如何刪除!警告:在應用程序啓動時檢測到1個線程:警告?rufus + puma + heroku警告

我puma.rb文件:

workers Integer(ENV['WEB_CONCURRENCY'] || 2) 
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) 
threads threads_count, threads_count 

preload_app! 

rackup  DefaultRackup 
port  ENV['PORT']  || 3000 
environment ENV['RACK_ENV'] || 'development' 

on_worker_boot do |worker_number| 
    # Worker specific setup for Rails 4.1+ 
    # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot 
    ActiveRecord::Base.establish_connection 
end 

日誌:

2016-09-03T14:21:24.742960+00:00 app[web.1]: [3] * Listening on tcp://0.0.0.0:53786 
2016-09-03T14:21:24.743135+00:00 app[web.1]: [3] ! WARNING: Detected 1 Thread(s) started in app boot: 
2016-09-03T14:21:24.743181+00:00 app[web.1]: [3] ! #<Thread:[email protected]/app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:563 sleep> - /app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:571:in `sleep' 
2016-09-03T14:21:24.743257+00:00 app[web.1]: [3] Use Ctrl-C to stop 
2016-09-03T14:21:24.754941+00:00 app[web.1]: [3] - Worker 0 (pid: 7) booted, phase: 0 
2016-09-03T14:21:24.756269+00:00 app[web.1]: [3] - Worker 1 (pid: 20) booted, phase: 0 
2016-09-03T14:21:25.525174+00:00 app[web.2]: ** [NewRelic][2016-09-03 14:21:25 +0000 web.2 (18)] INFO : Doing deferred dependency-detection before Rack startup 

回答

1

這很容易。停止使用rufus調度程序。它使用線程,這就是導致你的警告。

看:

2016-09-03T14:21:24.743181+00:00 app[web.1]: [3] ! 
<Thread:[email protected] 
/app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:563 
sleep> - 
/app/vendor/bundle/ruby/2.2.0/gems/rufus-scheduler-3.2.2/lib/rufus/scheduler.rb:571 
:in `sleep' 

魯弗斯調度顯然是警告的原因。

比照https://github.com/jmettraux/rufus-scheduler/issues/213

現在有另一種方式來看待事情:警告沒有被魯弗斯調度發出的,它是由彪馬發出。可能有一種方法可以禁用該警告,但對於具有Puma知識的人來說,這是一個問題。