我的部署设置是让 Heroku 预编译资产。我希望它们被预编译,以便我可以将它们发送到 CDN(通过asset_sync),我希望在 Heroku 上完成,所以我的 repo 中没有任何已编译的资产。我使用Heroku 的指南进行了设置,效果很好。我添加了turbo-sprockets-rails3以提高速度。它一直运行良好,然后停止了;我不知道为什么。
现在,当我部署(没有public/assets
)assets:precompile
Rake 任务在 Heroku 上超时。为了查看它真正需要多长时间,我进入了一个 shell ( heroku run bash
):
~ $ time bundle exec rake assets:precompile
AssetSync: YAML file found /app/config/asset_sync.yml settings will be merged into the configuration
AssetSync: Syncing.
Using: Directory Search of /app/public/assets
AssetSync: Done.
real 19m29.575s
user 17m43.690s
sys 0m28.480s
二十分钟!但是当我在本地运行它(2011 iMac)时,只需几分钟:
$ env RAILS_ENV=production time bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
~/.rbenv/versions/1.9.3-p327-perf/bin/ruby ~/.rbenv/versions/1.9.3-p327-perf/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Invoke assets:cache:clean (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
AssetSync: YAML file found ~/Code/Ruby/myproject-rails/config/asset_sync.yml settings will be merged into the configuration
** Execute assets:cache:clean
** Execute assets:precompile:all
AssetSync: Syncing.
Using: Directory Search of ~/Code/Ruby/myproject-rails/public/assets
Uploading: assets/application-3a6de939348195e9610f1321df27837a.js
Uploading: assets/application-3a6de939348195e9610f1321df27837a.js.gz
Uploading: assets/jquery.min-959a5819c76e1508f5a8655c289c0de8.map
Uploading: assets/jquery.min.map
Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js
Uploading: assets/rails_admin/rails_admin-76cfbf31a605916a55eee29464ca3e6d.js.gz
AssetSync: Done.
179.92 real 19.29 user 3.98 sys
一个多星期前我写了 Heroku 支持,几天后他们说他们会把它升级到他们的 Ruby 构建团队,但我仍然没有听到任何消息。Stack Overflow 上的聪明人有没有可能的解决方案?