Heroku rails 3.1 应用程序 - 在本地编译资产与在 slug 编译期间编译资产 [英] Heroku rails 3.1 app - compiling assets locally vs compiling assets during slug compilation

查看:29
本文介绍了Heroku rails 3.1 应用程序 - 在本地编译资产与在 slug 编译期间编译资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Heroku Cedar 堆栈上运行一个 Rails 3.1 应用程序,它支持资产管道.Heroku 列出了 3 种编译资源的方法

I'm running a rails 3.1 app on Heroku Cedar stack which supports the asset pipeline. Heroku lists 3 ways to compile assets

  1. 在本地编译资产.
  2. 在 slug 编译期间编译资产.
  3. 在运行时编译资产.

显然#3 对性能不利,Heroku 文档也反对它.但我不确定 #1 和 #2 之间哪个更好.

Obviously #3 is bad for performance and Heroku docs also recommend against it. But I'm not sure which is better between #1 and #2.

#1 要求您运行 rake assets:precompile 并在 git 中包含您的 public/assets 文件夹.您的 slug 会更大,但我认为部署站点的停机时间会更短.但是较大的 slug 大小意味着应用启动速度较慢,所以可能是一个问题.

#1 requires that you run rake assets:precompile and include your public/assets folder in git. Your slug will be bigger but I assume the downtime for deploying a site will be lower. But bigger slug size means slower app startup so maybe it's a wash.

#2 将使部署更新需要更长的时间,因为预编译是在 Heroku 端完成的.但是,您将拥有更小的蛞蝓,需要管理/记住的东西也更少.

#2 will make it take longer to deploy updates because of precompile being done on Heroku side. However, you will have a smaller slug and there's less to manage/remember.

我的问题是 - 哪个选项(#1 或 #2)最适合生产,为什么?

到目前为止,它看起来像选项 #2,但我想确保我没有忽略某些东西.

So far it looks like option #2 but I want to make sure I'm not overlooking something.

推荐答案

我在这里解决了其中一些问题和一个大问题:Rails 3.1.1 资产管道 Heroku 缓存问题

I addressed some of these issues and a big gotcha in my question here: Rails 3.1.1 asset pipeline Heroku caching gotcha

如果它对我有用,我更喜欢 #2,这样我就不必签入只会使 git 存储库膨胀的编译资产.

I'd prefer #2 if it worked for me so I don't have to checkin compiled assets which just bloats the git repository.

在 slug 编译期间编译资产不会导致任何额外的停机时间,因为您现有的应用程序将一直运行直到 slug 编译完成,所以不用担心.

Compiling assets during slug compilation won't result in any additional downtime because your existing app will stay up until slug compilation is complete so no worries there.

如果你能让它为你工作,我的建议是#2.如果你最终选择了 #1,那么最好的做法是在 rake assets:precompile 之前 git rm -r public/assets:precompile 以确保没有残留物.

My advice would be #2 if you can make it work for you. If you do end up going w/ #1 then take best practice would be to git rm -r public/assets before rake assets:precompile to make sure no cruft remains.

这篇关于Heroku rails 3.1 应用程序 - 在本地编译资产与在 slug 编译期间编译资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆