Rails assets precompile はメモリ不足の場合失敗する。

ずっとはまっていたのでメモ。

(in /www/app_name)
/home/hoge/.rvm/rubies/ruby-2.1.0/bin/ruby /home/hoge/.rvm/gems/ruby-2.1.0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
Crake aborted!

/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils.rb:68:in system'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils.rb:68:in
rake_system'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils.rb:42:in sh'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in
sh'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils.rb:80:in ruby'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/file_utils_ext.rb:37:in
ruby'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/actionpack-3.2.6/lib/sprockets/assets.rake:12:in ruby_rake_task'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/actionpack-3.2.6/lib/sprockets/assets.rake:21:in
invoke_or_reboot_rake_task'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/actionpack-3.2.6/lib/sprockets/assets.rake:29:in block (2 levels) in <top (required)>'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:246:in
call'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:246:in block in execute'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:241:in
each'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:241:in execute'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:184:in
block in invoke_with_call_chain'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:177:in invoke_with_call_chain'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/task.rb:170:in
invoke'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:143:in invoke_task'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:101:in
block (2 levels) in top_level'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:101:in each'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:101:in
block in top_level'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:110:in run_with_threads'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:95:in
top_level'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:73:in block in run'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:160:in
standard_exception_handling'
/home/hoge/.rvm/gems/ruby-2.1.0/gems/rake-10.0.4/lib/rake/application.rb:70:in run'
/home/hoge/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in
eval'
/home/hoge/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

[hoge@upsnap tmp]$ sudo tail -n 100 /var/log/messages

May 22 13:01:20 upsnap kernel: [51621603.815781] Free swap = 0kB
May 22 13:01:20 upsnap kernel: [51621603.815786] Total swap = 0kB
May 22 13:01:20 upsnap kernel: [51621603.816007] 157439 pages RAM
May 22 13:01:20 upsnap kernel: [51621603.816007] 4626 pages reserved
May 22 13:01:20 upsnap kernel: [51621603.816007] 10087 pages shared
May 22 13:01:20 upsnap kernel: [51621603.816007] 148401 pages non-shared
May 22 13:01:20 upsnap kernel: [51621603.816007] Out of memory: kill process 8093 (ruby) score 227837 or a child
May 22 13:01:20 upsnap kernel: [51621603.816007] Killed process 8093 (ruby) vsz:911348kB, anon-rss:105848kB, file-rss:0kB
May 22 13:01:20 upsnap kernel: [51621603.954129] rsyslogd invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0
May 22 13:01:20 upsnap kernel: [51621603.954144] rsyslogd cpuset=/ mems_allowed=0
May 22 13:01:20 upsnap kernel: [51621603.954152] Pid: 19196, comm: rsyslogd Not tainted 2.6.35.14-97.44.amzn1.x86_64 #1
May 22 13:01:20 upsnap kernel: [51621603.954160] Call Trace:

ということなので、メモリ不足(Out of memory)を解消してから再度実行したら成功しました。