为什么 Unicorn 正在寻找 rackup 文件 (config.ru),即使我正在指定配置?

Why is Unicorn looking for rackup file (config.ru) even though I am specifying a config?

我只是通过 SSH 连接到我的 Ubuntu 14.04 服务器实例,试图 bootstrap 我的 Unicorn 服务器用于 Rails 4.2 应用程序。

cd /home/sh0/app/current/api
bundle exec unicorn -E production -c /home/sh0/app/current/api/config/unicorn.rb

但是失败了!

/usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:657:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:77:in `reload'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:68:in `initialize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:100:in `initialize'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `new'
        from /usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/bin/unicorn:126:in `<top (required)>'
        from /home/sh0/app/releases/20150514055558/api/bin/unicorn:16:in `load'
        from /home/sh0/app/releases/20150514055558/api/bin/unicorn:16:in `<main>'

那么,为什么 没有 它找到该死的 config.ru 文件?它就在那里,用于本地开发目的 - 如果我只是在没有标志的情况下启动 Unicorn,它会发现它很好,就好像它在开发环境中一样。

bundle exec unicorn

正常(开发,不是我在这个环境中需要的生产)bootstrap OK:

I, [2015-05-14T06:00:44.081575 #5859]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
I, [2015-05-14T06:00:44.081818 #5859]  INFO -- : worker=0 spawning...
I, [2015-05-14T06:00:44.082427 #5859]  INFO -- : master process ready
I, [2015-05-14T06:00:44.083162 #5862]  INFO -- : worker=0 spawned pid=5862
I, [2015-05-14T06:00:44.083380 #5862]  INFO -- : Refreshing Gem list
I, [2015-05-14T06:00:45.399105 #5862]  INFO -- : worker=0 ready

好的,现在我将尝试在这两次尝试之间做一些事情。

在我的远程服务器上:

cd /home/sh0/app/current/api
unicorn -c config/unicorn.rb 

请注意此错误消息中的 working_directory

/usr/local/lib/ruby/gems/2.0.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:539:in `working_directory': config_file=config/unicorn.rb would not be accessible in working_directory=/home/sh0/app/current (ArgumentError)
  1. Unicorn 是一个机架式服务器。 Unicorn 将在 APP_ROOT

  2. 中查找 rackup 使用的 config.ru 文件
  3. 在您的生产服务器中,是否存在/home/sh0/app/current/api/config.ru

我的 config/unicorn.rb 配置错误。

我的 Rails 项目不在我的存储库的基础上,因此我需要更新该文件中默认指定的 working_directory

新配置为:

working_directory "/home/sh0/app/current/api"