Knowledge Base/Engine Yard Cloud Documentation/Migrate Applications

Upgrade to the Latest Ruby Version

Monty Mitra
posted this on April 4, 2012, 3:10 PM

Updated: May 28th, 2014

Even though your Ruby application is deployed on Engine Yard, its development lifecycle is not over. New major, minor or patch level versions of Ruby are periodically released. These newer versions contain security updates, performance increases and other valuable improvements, so it is in your best interest to keep your application running on the latest version.

This page outlines how to migrate an application to a newer version of Ruby. For example, from Ruby 1.9.2 to Ruby 1.9.3, or a newer patch level of the same version such as from Ruby 2.0.0p.451 to Ruby 2.0.0p481.

This page assumes that you have a Ruby application running on Engine Yard Cloud.

You can do the migration yourself as outlined below, or you can ask Engine Yard Professional Services to do the migration for you.

Migrate to the latest Ruby

High-level steps for migrating to the latest Ruby version:

  1. Test your application locally.
  2. Run your application in a staging environment .
  3. Run your application in a production environment.

Test your Application Locally

To test your application locally:

  1. If you use unix or Mac OS X, update your local environment to the new version of Ruby. We recommend using RVM to manage multiple versions of Ruby on your development machine.
  2. If you use Windows, update your local environment to the new version of Ruby using the instructions on railsinstaller.org.
  3. Reinstall the gems required for application.
  4. Test the application in your local environment and make any necessary fixes.

Run your Application in a Staging Environment

To run your application in a staging environment:

  1. If you don’t already have a staging environment, clone your existing production environment to create a staging environment. (Custom chef recipes and cron jobs are not copied over in the clone environment. See step 3.) If your app supports a ‘staging’ Rails environment, set the ‘Rails/Rack Environment’ field to “staging” in the clone dialog.
  2. When the staging server is configured, do the following:
    1. Click “Edit Environment”.
    2. Select the new version of Ruby in the Runtime field.
    3. (Optional) Select a corresponding new version of RubyGems in the RubyGems field.
    4. Submit the changes.
    5. Click the Apply button.
  3. Custom chef recipes and cron jobs are not copied over in the clone environment. If you rely on these, you must apply them manual to your new staging environment. Additionally, you will likely need to edit those chef recipes and cron jobs on the staging environment so that they are not inadvertently processing real client data (such as billing them or sending them mail). Depending on your app, you may also want to use an empty database instead of your copied production database.
  4. If Passenger is the application server stack, restart Nginx:
    1. SSH into the instance.
    2. Restart nginx using the following command: sudo /etc/init.d/nginx upgrade

      Note: We recommend using upgrade instead of restart for /etc/init.d/nginx because it restarts nginx gracefully. It starts a new nginx to handle new requests while the old one finishes off old requests before the old nginx is terminated.

  5. Deploy your application to ensure that you are testing the latest version of your application and that the deploy process works with the new version of Ruby (such as deploy hooks and migrations). If you’re actually using a different version of your app than the latest version, specify the desired branch/tag/commit hash in the Ref field.
  6. If you have any Ruby background processes such as Delayed Job or Resque, restart these to pick up the new Ruby version if your deploy hooks do not do it automatically.
  7. Test the application in the staging environment. Make any necessary fixes.

Run your Application in a Production Environment

To run your application in a production environment:

  1. Click Edit Environment on your production environment and select the new version of Ruby (and optionally RubyGems) as you did for staging. Submit the changes, and click the Apply button.

    If you choose to create a new production environment. You will also have to modify your DNS service for your domain to point to a new IP address if you take this alternative method.

  2. If Passenger is the application server stack, restart Nginx:
    1. SSH into the instance.
    2. Restart nginx using the following command: sudo /etc/init.d/nginx upgrade
  3. Deploy your application.
  4. If you have any Ruby background processes such as Delayed Job or Resque, restart these to pick up the new Ruby version if your deploy hooks do not do it automatically.

Troubleshooting

SymptomSolution

Bundle install and gem errors after upgrading an application to latest version of Ruby.

This can be caused by gems not being updated.

  1. Remove the bundled_gems directory:
    rm -rf /data/myapp/shared/bundled_gems
  2. Re-deploy the "myapp" application.

More information

For more information about...See...
Cloning an environment                                                                                             Clone an environment.
Creating an environment Create an environment.
Deploying an application Deploy your application.
SSHing into an instance Connect to your instance via SSH.                                                                                       

If you have feedback or questions about this page, add a comment below. If you need help, submit a ticket with Engine Yard Support.