Date post: | 26-Jun-2015 |
Category: |
Technology |
Upload: | nic-benders |
View: | 527 times |
Download: | 0 times |
GET YOUR ASS TO 1.9!
@nicbenders @ralphbod
http://nicbenders.com/ruby-19/
GET YOUR ASS TO 1.9!
@nicbenders @ralphbod
http://nicbenders.com/ruby-19/
Ruby 1.9 has been out since 2009
(Ruby 2.0 is even out now)
Ruby 1.8 will reach EOL in June
REE has already reached EOL
0
3750
7500
11250
15000
1.8.6 1.8.7 1.9.2 1.9.3 2.0.0
The New Relic App(as of mid-2012)
5 year old codebase
70,000 "Code LOC" and 59,000 "Test LOC"
Rails 2.3.14 (started as Rails 1.2.3)
REE-1.8.7-2010.02
Putting it off
Rearchitecting the app first
Do it all in a big spike!
Have a ruby_19 branch
STUPID THINGS WE TRIED
Do EVERYTHING on master
Setup a CI job for it
Start with your smaller apps
THE BIG IDEA
Be on latest Rails 2.3 or newer
Use rbenv / rvm everywhere
You already use Bundler, right?
Decent test coverage (50% is ok)
THE FOUNDATION
Getting the test suite to run
Upgrade obsolete 3rd party libs
THE HARD PART
Every commit is run both ways
Slowly burn-down the failures
(This took us several months)
THE GRIND
platforms :ruby_19 do gem 'debugger' gem 'crypt19'end
platforms :ruby_18 do gem 'ruby-debug' gem 'utility_belt' gem 'fastercsv' gem 'crypt', '1.1.4', :require => nilend
# Rails 2.3 did not get along with Ruby 1.9.3 until we did this# See - http://bit.ly/WPAj7aif ::RUBY_VERSION.split('.')[0,3] == ['1','9','3'] MissingSourceFile::REGEXPS.push( [/^cannot load such file -- (.+)$/i, 1] )end
# Prevent accidentally calling #[] on a number[Fixnum, Bignum].each do |k| k.class_eval do def [](*args) raise NoMethodError, "Calling #[] on numbers is wrong." end endend
# Use to_sym to ensure that you always have a# symbol in 1.8 or 1.9instance_methods.map(&:to_sym).include?(:connection)
require "csv"
# In Ruby 1.8, the library is called FasterCSV,# in 1.9 it's just CSV. So use some constant tricks# to make sure it's always "CSV" for usif CSV.const_defined? :Reader # Ruby 1.8 compatible require 'fastercsv' Object.send(:remove_const, :CSV) CSV = FasterCSVelse # CSV is now FasterCSV in ruby 1.9end
--- a/script/server+++ b/script/server@@ -1,3 +1,3 @@ #!/usr/bin/env ruby-require File.dirname(__FILE__) + '/../config/boot'+require File.expand_path('../../config/boot', __FILE__) require 'commands/server'
Mongrel
Ordered Hashes
Regex changes
Encodings
Enumerable String
Lambda Arity
Local dev environment first
Then each "Staging" env
Practice the roll-back plan
STARTING THE DEPLOY
Roll out servers one-by-one
Have extra capacity available
Be patient!
THE BIG DAY
Rotate the knowledge
Make it easy to test both locally
Background jobs were un-tested
THINGS TO DO BETTER
Changing the wheels on the bus at 80 mph: upgrading to Rails 3 on an active master branch
Andrew Bloomgarden and Julian Giuca
JOIN THE TEAMnewrelic.com/about/jobs