我在heroku上运行一个rails应用程序,我有两个web dynos。 我怎么能删除!警告:在app boot:warning中检测到1个线程?
我的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:0x007f382b59fca8@/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
答案 0 :(得分:1)
这很容易。停止使用rufus-scheduler。它使用线程,这是导致警告的原因。
看看:
2016-09-03T14:21:24.743181+00:00 app[web.1]: [3] !
<Thread:0x007f382b59fca8@
/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'
Rufus-scheduler显然是警告的原因。
Cf https://github.com/jmettraux/rufus-scheduler/issues/213
现在还有另一种看待事物的方法:rufus-scheduler不会发出警告,它是由Puma发出的。这可能是一种禁用警告的方法,但这对于了解Puma的人来说是一个问题。