简体   繁体   English

将Rails 2应用程序移植到新服务器

[英]Porting Rails 2 application to new server

I've posted a couple other questions during this process, but I have a better idea of what I'm trying to do so I thought I'd ask about that. 在此过程中,我还提出了其他几个问题,但是对于要执行的操作我有个更好的主意,所以我想问一下。

I've inherited a Rails 2.2.2 application, which is currently running in production form on a server I have access to. 我继承了一个Rails 2.2.2应用程序,该应用程序现在以生产形式在我可以访问的服务器上运行。 I'm trying to port that application over to my server, version control, etc. I first tried to copy over the source code and get it running under Rails 3 and the latest versions of gems, but that's proved to be much more difficult than I thought it would be. 我正在尝试将该应用程序移植到我的服务器,版本控制等上。我首先尝试复制源代码,并使其在Rails 3和gems的最新版本下运行,但是事实证明,这比困难得多。我以为会。 It seems like the best solution is to simply use the same version of Rails and other gems that the current system is using, and port over the application as-is. 似乎最好的解决方案是仅使用当前系统正在使用的相同版本的Rails和其他gem,并按原样通过应用程序进行移植。

So I'm wondering what the best way to do that is? 所以我想知道这样做的最好方法是什么? I can put the source in my version control system and set up Capistrano and Passenger the same way as they are now. 我可以将源代码放入版本控制系统中,并以与现在相同的方式设置Capistrano和Passenger。 The issue is getting all the gems over in the same version. 问题在于将所有宝石都放在同一版本中。 I've heard about freezing Rails and freezing gems, but a lot of the tutorials on it look a bit outdated. 我听说过冻结Rails和冻结gems,但是其中的许多教程看起来有些过时了。 Is it safe to freeze the gems on the currently-running production server, or should I just get a list of the gems and their versions and manually install them all on the new server I'm porting over to? 将gem冻结在当前正在运行的生产服务器上是否安全,还是我应该只获取gem及其版本的列表,然后将其全部手动安装到要移植到的新服务器上?

Edit : I followed tadman's suggestion and set up a Gemfile with all the gems and latest versions installed on the production server, but now I've gotten into a versioning mess with those, for example: 编辑 :我遵循了tadman的建议,并在生产服务器上安装了所有gems和最新版本的Gemfile,但是现在我陷入了与这些问题的版本控制,例如:

Bundler could not find compatible versions for gem "ruby2ruby":
  In Gemfile:
    merb-action-args (= 1.0.8.1) depends on
      ruby2ruby (>= 1.1.9)

    ambition (= 0.5.4) depends on
      ruby2ruby (1.1.8)

The production server has sometimes up to 4 versions of the same gem installed, but Bundler seems to only want to handle one version of each. 生产服务器有时会安装多达4个版本的同一gem,但是Bundler似乎只希望处理每个版本的一个版本。 Is there an easy way to solve a situation like this, or is it back to looking into freezing gems in production? 有没有一种简单的方法可以解决这种情况,还是可以追溯到生产中冻结的宝石?

Edit 2: I wound up removing versions from all gems except for rails and doing bundle install . 编辑2:我决定从除rails之外的所有gem中删除版本并进行bundle install So far, it seems to be working even though all the versions aren't matched exactly. 到目前为止,即使所有版本都不完全匹配,它似乎也可以正常工作。

Switching to Rails 3 might be a serious headache, but packaging up the historical versions of the gems can be significantly easier. 切换到Rails 3可能会让人头疼,但是打包宝石的历史版本会容易得多。 To a degree this is made easier by bundler where you can declare the specific versions you need in a Gemfile for your application. 在某种程度上, 捆绑程序使此操作变得更加容易,您可以在Gemfile为应用程序在Gemfile声明所需的特定版本。 While this is the de-facto method used in Rails 3, it is platform agnostic and can be used on any version of Rails as a distribution mechanism. 尽管这是Rails 3中使用的事实上的方法,但它与平台无关,可以在任何版本的Rails上用作分发机制。

You can usually determine the version of gems used with gem list as, unless otherwise specified in config/environment.rb the most recent version is selected automatically. 除非在config/environment.rb另外指定,否则通常可以将与gem list一起使用的gem list的版本确定为最新版本。 It is easy to transform a gem list into a Gemfile . 将gem列表转换为Gemfile很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM