gpt4 book ai didi

ruby-on-rails - Rails、Capistrano、Nginx、Unicorn - 应用程序已经初始化(RuntimeError)

转载 作者:行者123 更新时间:2023-12-04 23:26:22 24 4
gpt4 key购买 nike

谁能解释一下这个错误究竟指的是什么?

我在部署网站的新版本时遇到问题。

I,  INFO -- : reloading config_file=[snip]/current/config/unicorn.rb
I, INFO -- : Refreshing Gem list
E, ERROR -- : error reloading config_file=[snip]/current/config/unicorn.rb: Application has been already initialized. (RuntimeError)
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:135:in `initialize!'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
E, ERROR -- : [snip]/releases/20120907085937/config/environment.rb:5:in `<top (required)>'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
E, ERROR -- : config.ru:4:in `block in <main>'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
E, ERROR -- : config.ru:1:in `new'
E, ERROR -- : config.ru:1:in `<main>'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `eval'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn.rb:44:in `block in builder'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `call'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:696:in `build_app!'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:677:in `load_config!'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:303:in `join'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
E, ERROR -- : [snip]/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
I, INFO -- : reaped #<Process::Status: pid 3182 exit 0> worker=0
I, INFO -- : reaped #<Process::Status: pid 3185 exit 0> worker=1
I, INFO -- : reaped #<Process::Status: pid 3188 exit 0> worker=2
I, INFO -- : reaped #<Process::Status: pid 3191 exit 0> worker=3
I, INFO -- : worker=0 ready
I, INFO -- : worker=3 ready
I, INFO -- : worker=1 ready
I, INFO -- : worker=2 ready

unicorn .rb
root = "/home/[user]/apps/[site]/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"

listen "/tmp/unicorn.[site].sock", :backlog => 2048

worker_processes 4

preload_app true

timeout 30

before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
end

after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end

任何帮助表示赞赏 - 如果需要,我可以提取更多配置文件。

最佳答案

终于到了这一步。重读 Ryan Bates' Railscasts episode on zero downtime deployment 后,我注意到我使用 HUP 而不是 USR2 发出 unicorn restart/reload 命令。在改变这一点,并重新启用 ginettev 的答案中的代码(我之前为了理解这个问题而禁用的,我现在可以按照我的意愿进行部署。

更改就像更改我的 unicorn_init.sh 文件一样简单:

restart|reload)
sig HUP && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
run "$CMD"
;;


restart|reload)
sig USR2 && echo reloaded OK && exit 0
echo >&2 "Couldn't reload, starting '$CMD' instead"
run "$CMD"
;;

希望这对其他人有帮助!

关于ruby-on-rails - Rails、Capistrano、Nginx、Unicorn - 应用程序已经初始化(RuntimeError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12316302/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com