运行彪马时,出现此错误:
2019-04-22 19:59:10 -0500: Listen loop error: #<Errno::EBADF: Bad file descriptor>
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `select'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `handle_servers'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:360:in `block in run'
2019-04-22 19:59:10 -0500: Listen loop error: #<Errno::EBADF: Bad file descriptor>
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `select'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `handle_servers'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:360:in `block in run'
2019-04-22 19:59:10 -0500: Listen loop error: #<Errno::EBADF: Bad file descriptor>
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `select'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:386:in `handle_servers'
/Users/my_account/.rvm/gems/ruby-2.5.5/gems/puma-3.12.1/lib/puma/server.rb:360:in `block in run'
2019-04-22 19:59:10 -0500: Listen loop error: #<Errno::EBADF: Bad file descriptor>
我的puma.rb文件:
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RAILS_ENV'] || 'development'
on_restart do
puts "Puma restarting..."
end
app_dir = File.expand_path("../..", __FILE__)
log_dir = "#{app_dir}/log"
puts "LOG DIR: #{log_dir}"
if ENV['RAILS_ENV'] == 'production'
stdout_redirect "#{log_dir}/puma.stdout.log", "#{log_dir}/puma.stderr.log", true
end
Causes problem
on_worker_boot do
ActiveRecord::Base.establish_connection
end
Causes problem
preload_app!
此问题是由puma.rb配置文件引起的。我正在取消注释每一行以查看它们是否可以工作,但是在puma.rb文件中似乎包含任何代码行都只会导致Errno::EBADF: Bad file descriptor
错误。
答案 0 :(得分:0)
如果使用capistrano,则需要注释preload_app! 尝试使用分阶段重新启动而不是重新启动
我通过对puma.rb(配置文件)进行以下更改来解决了此问题。就我而言,我使用capistrano部署并重新启动puma。使用命令 phased-restart 的两个要求是:worker> = 2且不使用预加载
workers 2
#preload_app!
我的重启命令(分阶段重启):
pumactl -S /srv/apps/my_app/shared/tmp/pids/puma.state -F /srv/apps/my_app/shared/config/puma.rb phased-restart