哪些 Rails 部署技术最能克服环境差异?
我在 Ubuntu 上为我的教堂开发 Rails 应用程序。我们也在 Ubuntu 上使用托管 VPS。我使用 Capistrano 来部署定期更新。然而,不可避免的是,在我的本地机器上运行的应用程序在部署到主机后总是会出现一些问题,很可能是因为环境不同。
有哪些实践/技术可以简化部署,以便在本地测试和运行的内容同样可以在主机上运行。 (我已经采用了“供应商一切”方法。)
我的第一个想法是在本地 VPS 映像中开发/工作,该映像本身最终将被部署(某种虚拟设备)。有人这样做吗?
其他人如何做才能最大限度地减少环境差异造成的问题?哪些主机提供最佳部署选项?
I work on Ubuntu developing a Rails app for my church. We use a hosted VPS also on Ubuntu. I use Capistrano to deploy periodic updates. Inevitably, however, an app that works on my local box, always has a handful of problems after deploying to the host, most likely because the environments differ.
What are some practices/techniques to ease deployment so that what is tested and works locally is just as likely to work on the host. (I have already adopted the "vendor everything" approach.)
My first thought is to develop/work within a local VPS image that itself will eventually be deployed (a virtual appliance of sorts). Is anyone doing this?
What do others do to minimize issues that result from environmental differences? What hosts provide the best deployment options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试设置一个最能模仿您的制作环境的舞台环境。事实上,我使用我的一些服务器,创建一个子域(staged.mydomain.com)来测试宝石是否在正确的版本上等等。
我还使用只读用户来测试此阶段安装的实时数据。
这种方法可以帮助我们确保新部署能够正常工作,从而提前解决问题。
最好知道您经常处理哪些问题,以便尝试找到减少它们出现的方法。
Try setting up an stage environment that would mimic the most you can your production one. I in fact use some of my servers as this, creating a subdomain (staged.mydomain.com) to test wheter the gems an on the right version and alike.
I also use a READ-ONLY user to test with live and real data on this stage installation.
This approach help us to be sure that the new deployment will work just fine, solving issues beforehand.
It would be nice to know what kind of issues you deal with frequently to try to find a way of lessening their appearance.
尽可能确保您运行的是完全相同版本的 Ruby、完全相同版本的 Rails、完全相同的数据库设置以及完全相同的其他所有内容。实时设置和开发设置之间的差异越多,您可能遇到的问题就越多。
As far as possible make sure you're running the exact same version of Ruby, the exact same version of Rails, the exact same database setup, and the exact same everything else. The more differences between your live setup and your development setup, the more problems you're likely to encounter.
好吧,你实际上回答了你自己的问题。
如果您无法在生产环境中部署,您应该尝试将其完全镜像到您的计算机上。然后,您可以通过 VMWare 等程序对其进行测试。
根据我的经验,只有在非常关键的情况下才需要这样做。如果您的 Ruby/Rails(您可以在环境中指定的 gem 版本)相同,那么您在部署 Rails 应用程序时应该不会遇到任何问题。
事实上,很高兴知道您遇到了什么样的问题,这样我们就有希望为您提供更充分的解决方案。
Well you actually answered your own question.
If you can't deploy on a staging environment on the production box you should try and mirror that exactly to your computer. You can then test it via programs as VMWare etc.
In my experience this is only needed in really critical situations. If your Ruby/Rails (gem versions you can specify in your environment) are the same you shouldn't be having any problems deploying a Rails app.
Indeed it would be nice to know what kind of issues you are encountering so we can hopefully provide you with a more adequate solution.
请记住,大多数 Rails 开发人员都运行 OS X 并部署到 UNIX 服务器,因此我们从未遇到过任何类型的问题。
raby、rails、mysql等的版本当然应该是相同的。
Keep in mind that most Rails developers run OS X and deploy to a UNIX server and we never have any types of problems due to this.
Versions of raby, rails, mysql, etc.. should be the same of course.