在Capistrano中为生产阶段创建别名?

时间:2015-09-04 15:57:40

标签: ruby-on-rails capistrano capistrano3

我一直在使用Capistrano来部署我的最新项目。我有一个相当简单的设置,只有一个生产阶段(它创建了一个阶段,但我不使用它)。

我已经厌倦了键入cap production deploy来部署我的应用。我非常喜欢Rails如何处理这个问题,rails c prails console production相同。我希望能够输入:

cap p deploy

而不是较长的production版本。

我尝试过制作一个简单的别名:

ln production.rb p.rb

运行cap p deploy几乎完成所有部署步骤,然后在运行Rake迁移时死亡:

INFO [03d68697] Running ~/.rvm/bin/rvm 2.2.2 do bundle exec rake db:migrate as ubuntu@mydomain.com
DEBUG [03d68697] Command: cd /var/railsapps/metasmoke/releases/20150904155532 && ( RAILS_ENV=p ~/.rvm/bin/rvm 2.2.2 do bundle exec rake db:migrate )
DEBUG [03d68697]    Please require the stackprof gem falling back to fast_stack
DEBUG [03d68697]    
DEBUG [03d68697]    config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
DEBUG [03d68697]    
DEBUG [03d68697]      * development - set it to false
DEBUG [03d68697]      * test - set it to false (unless you use a tool that preloads your test environment)
DEBUG [03d68697]      * production - set it to true
DEBUG [03d68697]    
DEBUG [03d68697]    rake aborted!
DEBUG [03d68697]    ActiveRecord::AdapterNotSpecified: 'p' database is not configured. Available: ["default", "development", "test", "production"]
DEBUG [03d68697]    /var/railsapps/metasmoke/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.3/lib/active_record/connection_adapters/connection_specification.rb:248:in `resolve_symbol_connection'

我该怎么做?

1 个答案:

答案 0 :(得分:3)

您可能需要添加

set :rails_env, 'production'

到production.rb。 Capistrano从阶段名称推断出Rails环境名称。