独角兽陷入困境:刷新宝石列表

时间:2016-09-26 11:54:15

标签: ruby-on-rails unicorn

我正在使用Rails 4.0.0,Ruby 2.3和Unicorn。

我的应用程序工作正常,直到我尝试在我的Gemfile中添加nem gem。一切都像本地的魅力一样,但是当我使用Capistrano部署到DO时,我陷入了错误循环:

lst <- sapply(full$sentence,function(y){
which(sapply(part$name, function(x) {grepl(y,pattern = x)}))
})


lst2 <- lapply(seq_along(lst),function(x)  
{data.frame(full=rep(full[x,1],length(lst[[x]])),part=part[lst[[x]],1])})

do.call(rbind, lst2)

我不确切知道发生了什么,因为我可以在本地使用这个新Gem的代码但是在部署时它不会加载或不安装。

似乎这可能是在Google上搜索的语法问题,但不知道如何确定,因为很久以前我还没有添加Gem,所以语法错误可能太旧了。是否有一些工具来检查是否存在语法错误?我认为这很奇怪,因为它在本地工作。

我的Gemfile

E, [2016-09-26T11:40:29.801388 #24545] ERROR -- : reaped #<Process::Status: pid 4280 exit 1> worker=0
I, [2016-09-26T11:40:29.802952 #4287]  INFO -- : Refreshing Gem list
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/activesupport-4.0.0/lib/active_support/values/time_zone.rb:282: warning: circular argument reference - now
E, [2016-09-26T11:40:32.116762 #4287] ERROR -- : uninitialized constant Vimeo::HTTParty (NameError)
/home/deployer/apps/my_app/releases/20160924171252/app/controllers/webinars_controller.rb:2:in `<class:Vimeo>'
/home/deployer/apps/my_app/releases/20160924171252/app/controllers/webinars_controller.rb:1:in `<top (required)>'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
/home/deployer/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deployer/apps/my_app/releases/20160924171252/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `instance_eval'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/rack-1.5.5/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `eval'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn.rb:56:in `block in builder'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:752:in `build_app!'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:617:in `init_worker_process'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:639:in `worker_loop'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:508:in `spawn_missing_workers'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:519:in `maintain_worker_count'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:283:in `join'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
/home/deployer/apps/my_app/shared/bundle/ruby/2.3.0/bin/unicorn:23:in `<top (required)>'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:74:in `load'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli/exec.rb:27:in `run'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:332:in `exec'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:20:in `dispatch'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/cli.rb:11:in `start'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/exe/bundle:34:in `block in <top (required)>'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/home/deployer/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.1/exe/bundle:26:in `<top (required)>'
/home/deployer/.rvm/gems/ruby-2.3.0/bin/bundle:23:in `load'
/home/deployer/.rvm/gems/ruby-2.3.0/bin/bundle:23:in `<main>'
/home/deployer/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/home/deployer/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'

2 个答案:

答案 0 :(得分:0)

这里有类似的问题。当您更改Gemfile时会发生这种情况,使用unicorn:reload不会运行新代码。

解决了重启unicorn而不是重新加载它的问题。

如果您使用的是Capistrano,请更改后部署触发器 invoke 'unicorn:reload'来:

invoke 'unicorn:stop'
invoke 'unicorn:start'

根据https://github.com/tablexi/capistrano3-unicorn/issues/45 unicorn:restart无效。

答案 1 :(得分:0)

我们的问题是unicorn主进程没有正确重启,因为它被杀死了:

/bin/kill -s HUP `cat tmp/pids/unicorn.pid`

实际上并没有杀死unicorn主进程(只重新加载配置,请参阅SIGHUP文档)。通过运行ps -ef | grep 'unicorn'验证。

我们的问题解决了改变unicorn主进程的杀戮:

/bin/kill `cat tmp/pids/unicorn.pid`

PS:cat tmp/pids/unicorn.pid只输出独角兽主进程的PID。