【发布时间】:2013-09-19 18:10:02
【问题描述】:
我已经使用这个 gem 有一段时间了,只是尝试将一个实际的登台环境部署到我的登台服务器上,但我遇到了问题。 Unicorn 以命令 unicorn_rails 和 -E production 开头,尽管所有设置都是正确的 afaik。
我注意到在 deploy.rb 中我的 unicorn_bin 变量设置为 unicorn_rails。我在 deploy.rb 中去掉了这个设置。然而 unicorn:duplicate 仍然执行unicorn_rails 命令,此时默认应该是unicorn。
正如多阶段设置 wiki 文档中所述,我的 var 都设置为在 deploy/staging.rb 中暂存,但我注意到 -E 仍然设置为生产。
相关信息:
这是部署后 unicorn.log 文件的输出:
executing ["/var/www/apps/myapp/shared/bundle/ruby/2.0.0/bin/unicorn_rails", "-c", "/var/www/apps/bundio/current/config/unicorn.rb", "-E", "production", "-D", {12=>#<Kgio::UNIXServer:/tmp/bundio.socket>, 13=>#<Kgio::TCPServer:fd 13>}] (in /var/www/apps/bundio/current)
这是cap -T 的输出(默认为暂存)
# Environments
rails_env "staging"
unicorn_env "staging"
unicorn_rack_env "staging"
# Execution
unicorn_user nil
unicorn_bundle "/usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/bundle"
unicorn_bin "unicorn"
unicorn_options ""
unicorn_restart_sleep_time 2
# Relative paths
app_subdir ""
unicorn_config_rel_path "config"
unicorn_config_filename "unicorn.rb"
unicorn_config_rel_file_path "config/unicorn.rb"
unicorn_config_stage_rel_file_path "config/unicorn/staging.rb"
# Absolute paths
app_path "/var/www/apps/myapp/current"
unicorn_pid "/var/www/apps/myapp/shared/pids/unicorn.myapp.pid"
bundle_gemfile "/var/www/apps/myapp/current/Gemfile"
unicorn_config_path "/var/www/apps/myapp/current/config"
unicorn_config_file_path "/var/www/apps/myapp/current/config/unicorn.rb"
unicorn_config_stage_file_path
-> "/var/www/apps/myapp/current/config/unicorn/staging.rb"
还有一个奇怪的地方,unicorn_rails -E 标志应该引用 rails 环境,而 unicorn -E 应该引用 rack env——rack env 应该只获取值 developmentement 和 deployment,但它被设置为生产环境,这有点奇怪(见unicorn docs for settings of the RACK_ENV variable。
对此的任何见解将不胜感激。在我的登台服务器上,我还将 RAILS_ENV 设置为登台。我已经为另一个环境设置了 Rails 的东西,比如在我的环境文件夹中添加 staging.rb,在 database.yml 中添加一个 staging 部分等。
lib/capistrano-unicorn/config.rb 中关于 unicorn_rack_env 的重要语句:
_cset(:unicorn_env) { fetch(:rails_env, 'production' ) }
_cset(:unicorn_rack_env) do
# Following recommendations from http://unicorn.bogomips.org/unicorn_1.html
fetch(:rails_env) == 'development' ? 'development' : 'deployment'
end
提前致谢。
【问题讨论】:
标签: ruby-on-rails capistrano unicorn