2

运行cap deploy时,尝试编译资产时出现以下错误:

*** [err :: 205.186.157.163] /usr/local/ruby-enterprise/bin/ruby /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: 205.186.157.163] [DEPRECATION WARNING] Nested I18n namespace lookup under "activerecord.attributes.spree/order" is no longer supported
*** [err :: 205.186.157.163] [FATAL] failed to allocate memory
*** [err :: 205.186.157.163] rake aborted!

top我每次使用时都会看到内存达到最大值。我确实将 MediaTemple (ve) 框的内存分配增加到 1GB,但没有成功。

上下文:Spree 1.0.3、rails 3.1、MediaTemple (ve) 服务器,内存为 1GB。

有什么提示吗?

4

2 回答 2

3

实际上,我在这里按照 Ryan Bigg 的建议解决了我的问题:https ://github.com/spree/spree/issues/1183#issuecomment-5493863

原来sass-rails需要升级到 branch 3-1-stable,然后一切都运行得很好。

于 2012-05-03T19:36:28.147 回答
1

我认为这是 Rails 3.1 的一个已知问题,据说在 Rails 3.2 中已修复。还看到这里的另一个提及。我在全新安装 Rails 3.1 和 Spree 1.0 并且没有其他依赖项时遇到了同样的问题。

这是我解决它的方法:

在 Capfile 中,将其注释掉:

load 'deploy/assets'

在我的deploy.rb文件中,我复制deploy/assets了 spree-rails gem 提供的内容,但添加了precompile_quick任务。这编译了 CSS 和 JS,但看起来它实际上可能没有压缩 CSS 和 JS。

before 'deploy:finalize_update', 'deploy:assets:symlink'
after 'deploy:update_code', 'deploy:assets:precompile_quick'

namespace :deploy do
  namespace :assets do
    desc <<-DESC
      [internal] This task will set up a symlink to the shared directory \
      for the assets directory. Assets are shared across deploys to avoid \
      mid-deploy mismatches between old application html asking for assets \
      and getting a 404 file not found error. The assets cache is shared \
      for efficiency. If you cutomize the assets path prefix, override the \
      :assets_prefix variable to match.
    DESC
    task :symlink, :roles => assets_role, :except => { :no_release => true } do
      run <<-CMD
        rm -rf #{latest_release}/public/#{assets_prefix} &&
        mkdir -p #{latest_release}/public &&
        mkdir -p #{shared_path}/assets &&
        ln -s #{shared_path}/assets #{latest_release}/public/#{assets_prefix}
      CMD
    end

    desc <<-DESC
      Run the asset precompilation rake task. You can specify the full path \
      to the rake executable by setting the rake variable. You can also \
      specify additional environment variables to pass to rake via the \
      asset_env variable. The defaults are:

        set :rake,      "rake"
        set :rails_env, "production"
        set :asset_env, "RAILS_GROUPS=assets"
    DESC
    task :precompile_quick, :roles => assets_role, :except => { :no_release => true } do
      run "cd #{current_path} ; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile:primary"
      run "cd #{current_path} ; RAILS_ENV=#{rails_env} bundle exec rake assets:precompile:nondigest"
    end

    desc <<-DESC
      Run the asset clean rake task. Use with caution, this will delete \
      all of your compiled assets. You can specify the full path \
      to the rake executable by setting the rake variable. You can also \
      specify additional environment variables to pass to rake via the \
      asset_env variable. The defaults are:

        set :rake,      "rake"
        set :rails_env, "production"
        set :asset_env, "RAILS_GROUPS=assets"
    DESC
    task :clean, :roles => assets_role, :except => { :no_release => true } do
      run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:clean"
    end
  end
end
于 2012-05-03T01:07:28.797 回答