独角兽刷新宝石清单

时间:2019-03-06 20:53:05

标签: ruby-on-rails ruby unicorn

我正在尝试重新启动我的独角兽服务,看来它卡在了这个

  

[2019-03-06T20:45:05.938802#7614]信息-:刷新宝石列表

     

/usr/local/rvm/gems/ruby-2.5.1@citius_artis/gems/unicorn-5.5.0/lib/unicorn.rb:49:in

     

`builder中的块':参数数量错误(给定0,应为2)   (ArgumentError)

未更改gemfile上的任何内容

如果我运行rails s -e,则逐步启动rails

有什么想法吗?

我的unicorn.rb配置

APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))

# puts "APP ROOT ->>> #{APP_ROOT}"

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    # puts "RUBY HOME ->>> #{rvm_path}"
    rvm_lib_path = File.join(rvm_path, 'lib')
    # $LOAD_PATH.unshift rvm_lib_path
    # require 'rvm'
    # RVM.use_from_path! APP_ROOT
  rescue LoadError
    raise "RVM ruby lib is currently unavailable."
  end
end

ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

if ENV['RAILS_ENV'] == 'production'
  worker_processes 2
else
  worker_processes 2
end

working_directory APP_ROOT

preload_app true

timeout 60

listen APP_ROOT + "/tmp/sockets/unicorn.sock", :backlog => 64

pid APP_ROOT + "/tmp/pids/unicorn.pid"

stderr_path APP_ROOT + "/log/unicorn.stderr.log"
stdout_path APP_ROOT + "/log/unicorn.stdout.log"

before_fork do |server, worker|
  # puts "SERVER ->>> #{server}"

  defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect!

  old_pid = APP_ROOT + '/tmp/pids/unicorn.pid.oldbin'
  if File.exists?(old_pid) && server.pid != old_pid
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      # puts "Old master alerady dead"
    end
  end
end

after_fork do |server, worker|
  if defined?(ActiveRecord::Base)
    config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env]
    config['pool'] = ENV["DB_POOL"] || ENV['RAILS_MAX_THREADS'] || 5

    ActiveRecord::Base.establish_connection(config)
  end
end

2 个答案:

答案 0 :(得分:3)

我遇到了同样的问题,按照约翰·史密斯的建议,这对我有用:

bundle exec gem list | grep unicorn # returns unicorn (5.5.0)

将Gemfile更改为gem'unicorn','5.4.1'

bundle install

bundle exec gem list | grep unicorn # returns unicorn (5.4.1)

然后我能够无错误地重启独角兽

答案 1 :(得分:3)

似乎在5.5.0中引入了一个错误 https://bogomips.org/unicorn-public/20190307022859.mxz7m3mbspujo4c2@dcvr/

我测试了他的补丁版本,并且有效:

在Gemfile中设置独角兽版本

gem "unicorn", "~> 5.5.0.1.g6836"

然后运行bundle update unicorn