RAILS_ENV = rake预编译资产上的staging cap deploy失败

时间:2013-03-21 01:47:01

标签: ruby-on-rails deployment amazon-ec2 capistrano rubber

我在AWS上设置了t1.micro实例。我能够成功运行: RAILS_ENV=staging rubber:create_staging创建服务器,部署代码并运行应用程序。我对代码进行了一些更改,并希望部署到我的登台服务器,但是当我运行此命令时: RAILS_ENV=staging cap deploy 我收到以下错误:

 * executing "cd -- /mnt/domain-staging/releases/20130321005928 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile && cp -- /mnt/domain-staging/shared/assets/manifest.yml /mnt/domain-staging/releases/20130321005928/assets_manifest.yml"
    servers: ["staging.domain.com"]
    [staging.domain.com] executing command
 * [out :: staging.domain.com] /usr/local/rubies/1.9.3-p385/bin/ruby /mnt/domain-staging/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=staging RAILS_GROUPS=assets
 * [out :: staging.domain.com]
 * [out :: staging.domain.com] rake aborted!
 * [out :: staging.domain.com] Command failed with status (): [/usr/local/rubies/1.9.3-p385/bin/ruby /mnt...]
 * [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:9:in `ruby_rake_task'
 * [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:62:in `block (3 levels) in <top (required)>'
 * [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:19:in `invoke_or_reboot_rake_task'
 * [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
 * [out :: staging.domain.com] Tasks: TOP => assets:precompile:all
 * [out :: staging.domain.com] (See full trace by running task with --trace)
    command finished in 223523ms
failed: "/bin/bash -l -c 'cd -- /mnt/domain-staging/releases/20130321005928 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile && cp -- /mnt/domain-staging/shared/assets/manifest.yml /mnt/domain-staging/releases/20130321005928/assets_manifest.yml'" on staging.domain.com

我没有更改任何默认的capistrano配方,并且代码已成功部署一次。我已经能够为我的生产站点运行“cap deploy”而不是暂存站点。我无法在Google群组中找到任何内容,我们将不胜感激。

2 个答案:

答案 0 :(得分:2)

您需要调整application.rb以包含此内容:

if defined?(Bundler)
  Bundler.require(*Rails.groups(:assets => %w(development test), :profiling => %w[staging development]))
end

答案 1 :(得分:2)

这是因为运行“assets:precompile”时内存消耗很高。尝试重新启动EC2实例并再次运行部署,它可能会起作用。您还可以更改实例类型,以增强实例的内存并避免此类问题。