重新启动部署在 Passenger 上的 Rails 应用程序时切换 ruby

发布于 2024-10-31 01:33:41 字数 240 浏览 5 评论 0 原文

重新启动部署在 Passenger 上的 Rails 应用程序时是否可以从 Ruby 1.8.7 切换到 1.9.2?应该可以更改 httpd.conf 中的 PassengerRuby 并重新启动 Apache。我想知道如何在不每次都重新启动 Apache 的情况下完成此操作。

更多信息:我们有两个不同的应用程序,一个在 Rails 2.3.8 上,另一个在 3.0.5 上,且名称相同,并且希望在它们之间切换以进行测试。

谢谢。

Is it possible to switch from Ruby 1.8.7 to 1.9.2 when restarting a Rails app that is deployed on Passenger? It should be possible to change PassengerRuby in httpd.conf and restarting Apache. I want to know how it can be done without restarting Apache every time.

More info: We have two different apps, one on Rails 2.3.8 and one on 3.0.5 with the same name, and want to switch between them for testing purposes.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅浅淡淡 2024-11-07 01:33:41

是的,您可以切换使用的 ruby​​ 版本。使用 rvm (http://rvm.beginrescueend.com/),生活会变得轻松。然后,您可以在不同的 ruby​​ 环境中安装乘客 gem,当您在每个环境中执行此操作时,passenger-install-apache2-module 命令将告诉您要在 apache 配置文件中添加哪些内容。例如,我现在是(mac osx - 在其他 *nixes 中应该类似):

### system ruby and passenger
#LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
#PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-3.0.7
#PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

### rvm gemset [email protected] ruby and passenger
LoadModule passenger_module /Users/matt/.rvm/gems/[email protected]/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /Users/matt/.rvm/gems/[email protected]/gems/passenger-3.0.7
PassengerRuby /Users/matt/.rvm/wrappers/[email protected]/ruby

我可以注释/取消注释相应的注释并使用不同版本的 ruby​​ 重新启动 apache。这也适用于 ruby​​ 1.9.2 和 ruby​​ 企业版。

Yes you can switch which versions of ruby you use. Life is easy when you use rvm (http://rvm.beginrescueend.com/). Then you can install the passenger gem in different ruby environments, and when you do it in each environment, the passenger-install-apache2-module command will tell you what to put in the apache config file. For example, mine is now (mac osx - should be similar in other *nixes):

### system ruby and passenger
#LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
#PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-3.0.7
#PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

### rvm gemset [email protected] ruby and passenger
LoadModule passenger_module /Users/matt/.rvm/gems/[email protected]/gems/passenger-3.0.7/ext/apache2/mod_passenger.so
PassengerRoot /Users/matt/.rvm/gems/[email protected]/gems/passenger-3.0.7
PassengerRuby /Users/matt/.rvm/wrappers/[email protected]/ruby

I can comment/uncomment the appropriate one and restart apache with the different version of ruby. This also works for ruby 1.9.2 and ruby enterprise edition too.

め可乐爱微笑 2024-11-07 01:33:41

您不需要重新编译。您只需要更改 Web 服务器中的 PassengerRuby 选项即可。您确实需要重新启动 Web 服务器,但是仅触摸 restart.txt 是不够的。

您还可以使用 Passenger Standalone 来替代 bioneuralnet 提到的 Thin/Mongrel/Unicorn 反向代理设置。事实上,我们有一篇博客文章致力于使用 Passenger Standalone 运行多个 Ruby 版本:http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/

You don't need a recompile. You just just need to change the PassengerRuby option in the web server. You do need to restart the web server however, just touching restart.txt is not enough.

You can also use Passenger Standalone as a replacement for the Thin/Mongrel/Unicorn reverse proxy setup that bioneuralnet has mentioned. In fact we have a blog post dedicated to running multiple Ruby versions with Passenger Standalone: http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/

演多会厌 2024-11-07 01:33:41

由于 Passenger 有点“嵌入”到 Apache 中,所以我不可能在不重新启动的情况下切换 ruby​​ 解释器(甚至可能重新编译 Passenger?)。为了实现这种程度的灵活性,您可能需要研究某种反向代理设置,涉及在 Apache 或 Nginx 后面运行的独立应用程序服务器,例如 Thin、Unicorn 或 Mongrel。

如果这是不可能的,那么 Rails 2.3.8 和 3.0.5 应用程序完全可以在 Ruby 1.8.7 上运行。我在 1.8.7 上部署了多个 Rails 3 应用程序,但希望这种情况很快就会改变。假设您的 3.0.5 应用程序没有明确的 1.9 依赖项,为什么不能在单独的虚拟主机中的 1.8 上并排运行它们呢?

Since Passenger kind of "embeds" itself into Apache, I don't it's possible to switch ruby interpreters without a restart (and possibly even a recompile of Passenger?). To achieve that level of flexibility you may need to look into some kind of reverse-proxy setup involving a stand-alone app server like Thin, Unicorn or Mongrel, running behind Apache or Nginx.

If that's out of the question, then it is strictly possible for Rails 2.3.8 and 3.0.5 apps to both run on Ruby 1.8.7. I have several Rails 3 apps deployed on 1.8.7, though hopefully that will change soon. Assuming your 3.0.5 app doesn't have explicit 1.9 dependencies, why can't you just run them both side by side on 1.8 in separate virtual hosts?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文