I have a few Rails apps, each running on their own server. They run under Passenger-apache, and currently under ruby 1.9.3. Currently, they run under a ruby installed and managed with rbenv.
I'd like to upgrade them all to ruby 2.2.x. As long as I'm doing this, I'd like to upgrade them from passenger 4.x to 5.x as well.
Let's assume I've tested them all on my development box and am confident they run fine under ruby 2.2.
As I think through this, I get very confused about the best way to do this -- especially with minimal production downtime.
I guess I'd start out by installing ruby 2.2 under rbenv, which theoretically shouldn't disturb the running apps. Passenger is installed under a particular ruby, but then has the option of running apps under different rubies. Should I install the latest passenger first, under the new ruby 2.2, but configured to run the existing apps under the old ruby? And then upgrading the apps to the new ruby... I guess involves running bundle install again, to get all dependencies installed under the new ruby?
Or something else entirely? Is there a way to do this that is relatively safe, and will have limited or zero downtime for my apps?
Has anyone done this before? I'm fairly familiar with all the pieces already, and can brainstorm possible approaches myself, but when I start, there are too many places where I'm not sure what the best approach is. What I could really use is advice from someone who has already done this, or is otherwise pretty sure that what they recommend will work as they say -- not just guesses about things you haven't done that might work. Thanks!
Make sure that your applications work under the new ruby version. I have had some legacy Rails 3.2.x applications that works up to ruby 2.1.5, but breaks in ruby 2.2.x. You should be fine with updating your ruby and passenger versions.
Since each application runs on their own server, you don't have to really worry about running multiple versions of passenger. You should be able to install the new version ruby on each server, install the gems, update apache to the newer passenger and restart apache to have everything take effect. Worst case, you can clone your servers to a virtual environment and test everything prior to doing it on production. This would help you minimize downtime as you would have any workarounds and/or research of bugs done prior to touching the production environment.
Related
We use Ubuntu 12.04 TLS, Ruby 1.9.3, Rails 3.2.12, and RVM on our production server.
We want to upgrade Ruby from 1.9.3 to 2.2 (or whatever the latest one is), without updating Rails.
I have three questions:
Are there any caveats in doing that, any inconsistensies, deprecated methods? Is there any chance that site will stop working?
Considering that we are using RVM, would it be possible to get back to the version we are using right now (if anything goes wrong)?
Would it be necessary to re-install all the gems that we are using right now?
Thanks in advance!
Always presume the whole machine is going to be trashed beyond repair by this process. Prepare for the worst, hope for the best. If you don't have a test machine, you can build one with a tool like Vagrant. Once you have a procedure that works, repeat it on your production system.
Ruby 2.1.1 is the current version. You'll also want to look at upgrading Rails itself to avoid a bunch of nasty vulnerabilities. 3.2.17 is the version to target here.
RVM does make it easier to upgrade things, but you'll also need to upgrade your launcher (e.g. Passenger) to use the newer Ruby version. Yes, it is possible to back out, but this is not always convenient.
One trick that might help rescue from disaster is checking your /etc directory into a local Git repository. This allows you to rollback any configuration changes you make, as well as see what changes you've actually made through the course of your upgrades.
Any change to the base Ruby version does require re-installing all gems. If you're using Bundler or an automated deployment tool this should be fairly automatic.
weird issue. I have passenger installed on an Apache 2 server, and trying to get a Rails application running. First time deploying a rails application, so not really sure what's going on.
Passenger gives me this error:
But the problem is that 1.9.2-p136 isn't even installed on my system. I removed all ruby versions and completely reinstalled ruby with 1.9.3-p448. (I also have 2.0.0 but I default to 1.9.3)
Not seeing how passenger is even recognizing that I am running a build of ruby that doesnt exist on my system.
I'm hoping this is my last obstacle to getting this started. I have dealt with about every issue that I could have trying to get this damn rails app up. I'll tell you, they make up for how easy it is to develop with by making it impossible to deploy.
Thanks all!
1.9.2 is probably the system ruby (or was, at some point). Now, how in the heck Passenger is running on that while simultaneously using gems from an rvm install of 1.9.3...
Anyway, check your Passenger config. Make sure the PassengerDefaultRuby (if present) and PassengerRuby directives are pointing to the correct version; Passenger often gets confused by varying PATHs, and this is especially true with rvm where you may be running a different version in your user shell session than system tools will find on their own.
There's a reason people like solutions like Unicorn, Puma, and Rainbows. ;) Passenger, once you get it compiled and configured, is pretty much fire and forget, but getting to that point can be painful.
This might be a paranoid question, but am I likely to break anything in my ruby on rails app if I install RVM AFTER having installed rails?
Thanks in advance for any peace of mind you can offer me :P
Your App will be fine - but after installing RVM it will take some configuration get everything running back the way it was. This has nothing to do with your app, but with your environment. If you follow the installation instructions EXACTLY then it will not be too difficult.
If you are planning to do this on a production server then be prepared for some downtime.
Once a year or so, I need to update a few rails apps. This means that while I know the ruby language... I forget and don't keep up with the best practices of setting up the rails environment on osx 10.6.7. In the past year I got a new mbp... so I need to reconfig everything. One of the apps is 2.0.2 and two other apps are 2.3.x... so I'd like to also upgrade these as I make changes to them. I've heard good things about homebrew and pow so I installed those. And all would be well if I was writing a new app from scratch... but how do I run a rails v.2.0.2 app with this setup?
There is no way to run a rails 2.0.2 app with pow, unfortunately. Pow is a tool for running rack apps, and rails wasn't build on top of rack until version 2.3.
OSX 10.5 comes with Ruby 1.8.6 I believe, but I see a lot of tutorials that recommend installing the latest version of Ruby from source. I've done this in the past and it's caused minor issues down the road if I install something which expects Ruby to be in the default location and it's not (Phusion Passenger pref pane, for instance).
What I'm wondering is if the default version of Ruby is good enough to use for development purposes, so there's no conflicts or multiple versions of Ruby floating about? Obviously the default Rubygems and Rails versions would need to be upgraded, but I'm specifically wondering about the default version of Ruby that comes with 10.5.
Rails 3 will require Ruby 1.8.7 and we're already recommending 1.8.7 for Rails 2.3.4. I'd strongly recommend upgrading.
1.8.6 will be fine for a local dev box. Personally I always install what's on the production box -- usually Ruby Enterprise -- but yea, if you don't want to deal with the hassles involved with replacing ruby entirely, there's no big disaster waiting for you with the stock stuff.
If you do want to keep current (probably a good idea for a serious application) and make sure you're running the same ruby as your production environment then you could try this tutorial (I've used a previous iteration) on handling those hassles.
The Rails team themselves recommend Ruby 1.8.7 for doing Rails development with any of the most recent releases.
I'd also highly recommend that you use the same version of Ruby for development as what will be in your 'production' environment. Avoids surprises.
The Ruby on Rails download page recommends 1.8.7 but says 1.8.6 still works and I'm finding no problems.
I personally do not like the Ruby implementation on the Mac, as I had a a lot of problems with MySql, Postgres, and other gems, always being obscure compilation problems which required me to install XCode and then compile all sorts of obscure libraries. In the end I solved my problems by installing Ubuntu 8.10 on VirtualBox under the Mac, and now everything works great!!!!
Also, when I switched to Snow Leapard I had a lot of the Ruby gems break as well. Also, I would recommend using Ruby 1.9, definitely much faster than 1.8.6 IMHO, again, running best on Ubuntu, NOT Mac.
I guess I would also like to add that many Unix die hards will disagree with me on this post, as things on the Mac CAN be made to work, but I guess I'm just lazy, and would rather have things "work out of the box".
I run REE (Ruby Enterprise Edition) simply because it runs my specs faster than the regular version (about 20%, sometimes more).
It's also nice that it comes with passenger and some of other things you usually want.